-
Notifications
You must be signed in to change notification settings - Fork 0
DiGraph pyDocs
shaCode256 edited this page Mar 4, 2021
·
1 revision
def __init__(self):
"""
Constructor
"""
def v_size(self) -> int:
"""
Returns the number of vertices in this graph
@return: The number of vertices in this graph
"""
def e_size(self) -> int:
"""
Returns the number of edges in this graph
@return: The number of edges in this graph
"""
def get_all_v(self) -> dict:
"""return a dictionary of all the nodes in the Graph, each node is represented using apair (key, node_data)"""
def all_out_edges_of_node(self, id1: int) -> dict:
"""return a dictionary of all the nodes connected from node_id , each node is represented using a pair (key,
weight)"""
def all_in_edges_of_node(self, id1: int) -> dict:
"""return a dictionary of all the nodes connected to (into) node_id ,
each node is represented using a pair (key, weight)"""
def get_mc(self) -> int:
"""
Returns the current version of this graph,
on every change in the graph state - the MC should be increased
@return: The current version of this graph.
"""
def add_edge(self, id1: int, id2: int, weight: float) -> bool:
"""
Adds an edge to the graph.
@param id1: The start node of the edge
@param id2: The end node of the edge
@param weight: The weight of the edge
@return: True if the edge was added successfully, False o.w.
Note: If the edge already exists or one of the nodes dose not exists the functions will do nothing
"""
def add_node(self, node_id: int, pos: tuple = None) -> bool:
"""
Adds a node to the graph.
@param node_id: The node ID
@param pos: The position of the node
@return: True if the node was added successfully, False o.w.
Note: if the node id already exists the node will not be added"""
def remove_edge(self, node_id1: int, node_id2: int) -> bool:
"""
Removes an edge from the graph.
@param node_id1: The start node of the edge
@param node_id2: The end node of the edge
@return: True if the edge was removed successfully, False o.w.
Note: If such an edge does not exists the function will do nothing
"""
def remove_node(self, node_id: int) -> bool:
"""
Removes a node from the graph.
@param node_id: The node ID
@return: True if the node was removed successfully, False o.w.
Note: if the node id does not exists the function will do nothing
"""
def __repr__(self):
""" ToString method """
def as_dict(self) -> dict:
""" The method arranges the graph, by our demand (as json format) """
def set_mc(self):
"""Initialization the number of changes"""
def __eq__(self, other) -> bool:
""" The method compares between 2 graphs, by the keys of nodes and their position, and by the pairs (src, dest) of edges and their weights"""