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, BidirectionalNetwork

Same 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_edge

Add an edge to the network.

add_edges_from

Add all the edges in ebunch_to_add.

add_lost_message

Add a message to the lost messages from node u to node v.

add_node

Add node to network.

add_nodes_from

Add multiple nodes.

add_observers

add_transit_message

Add a message to the in-transit messages from node u to node v.

add_weighted_edges_from

Add weighted edges in ebunch_to_add with specified weight attr

adjacency

Returns an iterator over (node, adjacency dict) tuples for all nodes.

avg_degree

Calculate the average degree of the network.

clear

Remove all nodes and edges from the graph.

clear_edges

Remove all edges from the graph without altering nodes.

clear_observers

communicate

Pass all messages from node's outboxes to its neighbors inboxes.

copy

Return a copy of the graph.

deliver_to

Deliver a message to a destination node in the network.

edge_subgraph

Returns the subgraph induced by the specified edges.

get_dic

Return all network data in the form of a dictionary.

get_edge_data

Returns the attribute dictionary associated with edge (u, v).

get_fig

Get the figure object representing the network visualization.

get_lost_messages

Get lost messages from node u to node v.

get_size

Returns network width and height based on nodes positions.

get_transit_messages

Get messages in transit from node u to node v.

get_tree_net

Returns a new network with edges that are not in a tree removed.

has_edge

Returns True if the edge (u, v) is in the graph.

has_node

Returns True if the graph contains the node n.

in_neighbors

increment_node_clocks

Increment the clock of all nodes in the network.

is_connected

is_directed

Returns True if graph is directed, False otherwise.

is_multigraph

Returns True if graph is a multigraph, False otherwise.

modify_avg_degree

DEPRECATED AND UNTESTED

nbunch_iter

Returns an iterator over nodes contained in nbunch that are also in the graph.

neighbors

Returns an iterator over all neighbors of node n.

node_by_id

Returns the first node with the given id.

nodes

A NodeView of the Graph as G.nodes or G.nodes().

nodes_sorted

Returned sorted nodes by id.

notify_observers

number_of_edges

Returns the number of edges between two nodes.

number_of_nodes

Returns the number of nodes in the graph.

order

Returns the number of nodes in the graph.

out_neighbors

recalculate_edges

Recalculate edges for given nodes or for all self.nodes().

remove_edge

Remove the edge between u and v.

remove_edges_from

Remove all edges specified in ebunch.

remove_node

Remove a node from the network.

remove_nodes_from

Remove multiple nodes.

reset

Reset the network to its initial state.

reset_all_nodes

Reset all nodes in the network.

savefig

show

Get and show the figure object representing the network visualization.

size

Returns the number of edges or total of all edge weights.

subgraph

Returns a SubGraph view of the subgraph induced on nodes.

subnetwork

Returns a NetworkType instance with the specified nodes and edges.

to_directed

Returns a directed representation of the graph.

to_directed_class

Returns the class to use for empty directed copies.

to_undirected

Returns an undirected copy of the graph.

to_undirected_class

Returns the class to use for empty undirected copies.

update

Update the graph using nodes/edges/graphs as input.

validate_params

Validate if given network params match its real params.

Attributes

adj

Graph adjacency object holding the neighbors of each node.

degree

A DegreeView for the Graph as G.degree or G.degree().

edges

An EdgeView of the Graph as G.edges or G.edges().

environment

name

String identifier of the graph.