Source code for roksana.attack_methods.custom_attack

"""
MyCustomAttack Module
----------------------
This module provides an example of how to implement a custom graph attack algorithm. Custom routines should
inherit from the `BaseAttack` class and override the `execute` method to define the attack logic.

Classes:
    - MyCustomAttack: An example implementation of a custom attack.

Usage:
    To use the `MyCustomAttack` class, follow the example below:
    ----------------------------------------------------------------------
    from custom_attack import MyCustomAttack

    attack = MyCustomAttack()
    result = attack.execute(data, params={'custom_param': 'value'})
    ----------------------------------------------------------------------
"""

from .base_attack import BaseAttack
from typing import Any

[docs] class MyCustomAttack(BaseAttack): """ MyCustomAttack Class --------------------- Example implementation of a custom attack. This class demonstrates how to inherit from the `BaseAttack` class and implement the `execute` method for modifying a graph dataset. Methods: - execute: Executes the custom attack on the input data. """
[docs] def execute(self, data: Any, params: dict) -> Any: """ Execute the custom attack logic. Args: data (Any): The input graph dataset to modify. params (dict): A dictionary of parameters to configure the attack. Returns: Any: The modified graph dataset after applying the custom attack. """ # Implement custom attack logic here modified_data = data # Modify data as needed return modified_data