Documentation Index
Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
Use this file to discover all available pages before exploring further.
class NetworkXToolkit(BaseToolkit):
_get_nx
Lazily import networkx module when needed.
init
def __init__(
self,
timeout: Optional[float] = None,
graph_type: Literal['graph', 'digraph', 'multigraph', 'multidigraph'] = 'graph'
):
Initializes the NetworkX graph client.
Parameters:
- timeout (Optional[float]): The timeout value for API requests in seconds. If None, no timeout is applied. (default: :obj:
None)
add_node
def add_node(self, node_id: str, **attributes: Any):
Adds a node to the graph.
Parameters:
- node_id (str): The ID of the node.
- attributes (dict): Additional node attributes.
add_edge
def add_edge(
self,
source: str,
target: str,
**attributes: Any
):
Adds an edge to the graph.
Parameters:
- source (str): Source node ID.
- target (str): Target node ID.
- attributes (dict): Additional edge attributes.
get_nodes
Returns:
List[str]: A list of node IDs.
get_edges
Returns:
List[Tuple[str, str]]: A list of edges as (source, target).
get_shortest_path
def get_shortest_path(
self,
source: str,
target: str,
weight: Optional[Union[str, Callable]] = None,
method: Literal['dijkstra', 'bellman-ford'] = 'dijkstra'
):
Finds the shortest path between two nodes.
Parameters:
- method (
Literal['dijkstra', 'bellman-ford'], optional): Algorithm to compute the path. Ignored if weight is None. (default: :obj:'dijkstra')
Returns:
List[str]: A list of nodes in the shortest path.
compute_centrality
def compute_centrality(self):
Returns:
Dict[str, float]: Centrality values for each node.
serialize_graph
def serialize_graph(self):
Returns:
str: The serialized graph in JSON format.
deserialize_graph
def deserialize_graph(self, data: str):
Loads a graph from a serialized JSON string.
Parameters:
- data (str): The JSON string representing the graph.
export_to_file
def export_to_file(self, file_path: str):
Exports the graph to a file in JSON format.
Parameters:
- file_path (str): The file path to save the graph.
import_from_file
def import_from_file(self, file_path: str):
Imports a graph from a JSON file.
Parameters:
- file_path (str): The file path to load the graph from.
clear_graph
Clears the current graph.
Returns:
List[FunctionTool]: A list of FunctionTool objects for the
toolkit methods.