pydistsim.network.rangenetwork.BidirectionalRangeNetwork
- class BidirectionalRangeNetwork(incoming_graph_data=None, environment: Environment | None = None, rangeType: RangeType | None = None, behavioral_properties: NetworkBehaviorModel | None = None, **kwargs)[source]
Bases:
RangeNetworkMixin,BidirectionalNetworkSame as RangeNetwork but with bidirectional edges (undirected graph).
Initialize a graph with edges, name, or graph attributes.
Parameters
- incoming_graph_datainput graph (optional, default: None)
Data to initialize graph. If None (default) an empty graph is created. The data can be an edge list, or any NetworkX graph object. If the corresponding optional Python packages are installed the data can also be a 2D NumPy array, a SciPy sparse array, or a PyGraphviz graph.
- attrkeyword arguments, optional (default= no attributes)
Attributes to add to graph as key=value pairs.
See Also
convert
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G = nx.Graph(name="my graph") >>> e = [(1, 2), (2, 3), (3, 4)] # list of edges >>> G = nx.Graph(e)
Arbitrary graph attribute pairs (key=value) may be assigned
>>> G = nx.Graph(e, day="Friday") >>> G.graph {'day': 'Friday'}
Methods
__init__Initialize a graph with edges, name, or graph attributes.
add_edgeAdd an edge to the network.
add_edges_fromAdd all the edges in ebunch_to_add.
add_lost_messageAdd a message to the lost messages from node u to node v.
add_nodeAdd node to network.
add_nodes_fromAdd multiple nodes.
add_observersadd_transit_messageAdd a message to the in-transit messages from node u to node v.
add_weighted_edges_fromAdd weighted edges in ebunch_to_add with specified weight attr
adjacencyReturns an iterator over (node, adjacency dict) tuples for all nodes.
avg_degreeCalculate the average degree of the network.
clearRemove all nodes and edges from the graph.
clear_edgesRemove all edges from the graph without altering nodes.
clear_observerscommunicatePass all messages from node's outboxes to its neighbors inboxes.
copyReturn a copy of the graph.
deliver_toDeliver a message to a destination node in the network.
edge_subgraphReturns the subgraph induced by the specified edges.
get_dicReturn all network data in the form of a dictionary.
get_edge_dataReturns the attribute dictionary associated with edge (u, v).
get_figGet the figure object representing the network visualization.
get_lost_messagesGet lost messages from node u to node v.
get_sizeReturns network width and height based on nodes positions.
get_transit_messagesGet messages in transit from node u to node v.
get_tree_netReturns a new network with edges that are not in a tree removed.
has_edgeReturns True if the edge (u, v) is in the graph.
has_nodeReturns True if the graph contains the node n.
in_neighborsincrement_node_clocksIncrement the clock of all nodes in the network.
is_connectedis_directedReturns True if graph is directed, False otherwise.
is_multigraphReturns True if graph is a multigraph, False otherwise.
modify_avg_degreeDEPRECATED AND UNTESTED
nbunch_iterReturns an iterator over nodes contained in nbunch that are also in the graph.
neighborsReturns an iterator over all neighbors of node n.
node_by_idReturns the first node with the given id.
nodesA NodeView of the Graph as G.nodes or G.nodes().
nodes_sortedReturned sorted nodes by id.
notify_observersnumber_of_edgesReturns the number of edges between two nodes.
number_of_nodesReturns the number of nodes in the graph.
orderReturns the number of nodes in the graph.
out_neighborsrecalculate_edgesRecalculate edges for given nodes or for all self.nodes().
remove_edgeRemove the edge between u and v.
remove_edges_fromRemove all edges specified in ebunch.
remove_nodeRemove a node from the network.
remove_nodes_fromRemove multiple nodes.
resetReset the network to its initial state.
reset_all_nodesReset all nodes in the network.
savefigshowGet and show the figure object representing the network visualization.
sizeReturns the number of edges or total of all edge weights.
subgraphReturns a SubGraph view of the subgraph induced on nodes.
subnetworkReturns a NetworkType instance with the specified nodes and edges.
to_directedReturns a directed representation of the graph.
to_directed_classReturns the class to use for empty directed copies.
to_undirectedReturns an undirected copy of the graph.
to_undirected_classReturns the class to use for empty undirected copies.
updateUpdate the graph using nodes/edges/graphs as input.
validate_paramsValidate if given network params match its real params.
Attributes
adjGraph adjacency object holding the neighbors of each node.
degreeA DegreeView for the Graph as G.degree or G.degree().
edgesAn EdgeView of the Graph as G.edges or G.edges().
environmentnameString identifier of the graph.