Base class for undirected graphs. Nodes are allowed for any hashable Python objects, including int, string, dict, etc. Edges are stored as Python dict type, with optional key/value attributes. Parameters ---------- graph_attr : keywords arguments, optional (default
| 14 | |
| 15 | |
| 16 | class Graph: |
| 17 | """ |
| 18 | Base class for undirected graphs. |
| 19 | |
| 20 | Nodes are allowed for any hashable Python objects, including int, string, dict, etc. |
| 21 | Edges are stored as Python dict type, with optional key/value attributes. |
| 22 | |
| 23 | Parameters |
| 24 | ---------- |
| 25 | graph_attr : keywords arguments, optional (default : None) |
| 26 | Attributes to add to graph as key=value pairs. |
| 27 | |
| 28 | See Also |
| 29 | -------- |
| 30 | DiGraph |
| 31 | |
| 32 | Examples |
| 33 | -------- |
| 34 | Create an empty undirected graph with no nodes and edges. |
| 35 | |
| 36 | >>> G = eg.Graph() |
| 37 | |
| 38 | Create a deep copy graph *G2* from existing Graph *G1*. |
| 39 | |
| 40 | >>> G2 = G1.copy() |
| 41 | |
| 42 | Create an graph with attributes. |
| 43 | |
| 44 | >>> G = eg.Graph(name='Karate Club', date='2020.08.21') |
| 45 | |
| 46 | **Attributes:** |
| 47 | |
| 48 | Returns the adjacency matrix of the graph. |
| 49 | |
| 50 | >>> G.adj |
| 51 | |
| 52 | Returns all the nodes with their attributes. |
| 53 | |
| 54 | >>> G.nodes |
| 55 | |
| 56 | Returns all the edges with their attributes. |
| 57 | |
| 58 | >>> G.edges |
| 59 | |
| 60 | """ |
| 61 | |
| 62 | gnn_data_dict_factory = dict |
| 63 | raw_selfloop_dict = dict |
| 64 | graph_attr_dict_factory = dict |
| 65 | node_dict_factory = dict |
| 66 | node_attr_dict_factory = dict |
| 67 | adjlist_outer_dict_factory = dict |
| 68 | adjlist_inner_dict_factory = dict |
| 69 | edge_attr_dict_factory = dict |
| 70 | node_index_dict = dict |
| 71 | |
| 72 | def __init__(self, incoming_graph_data=None, extra_selfloop=False, **graph_attr): |
| 73 | self.graph = self.graph_attr_dict_factory() |
no outgoing calls