netket.graph.NetworkX

class netket.graph.NetworkX(graph)[source]

Bases: netket.graph.abstract_graph.AbstractGraph

Wrapper for a networkx graph

__init__(graph)[source]

Constructs a netket graph from a networkx graph.

Parameters

graph (Graph) – A networkx graph (might be a networkx.Graph or a networkx.MultiGraph)

Examples

A graph of nodes [0,1,2] with edges [(0,1), (0,2), (1,2)]

>>> import netket
>>> import networkx
>>> nx_g = networkx.Graph([(0,1), (0,2), (1,2)])
>>> nk_g = netket.graph.NetworkX(nx_g)
>>> print(nk_g.n_nodes)
3
Attributes
n_edges

The number of edges in the graph.

Return type

int

n_nodes

The number of nodes (or vertices) in the graph

Return type

int

Methods
adjacency_list()[source]

List containing the adjacency list of the graph where each node is represented by an integer in [0, n_nodes)

Return type

List[List]

automorphisms()[source]

Symmetry group containing the automorphisms of the graph

Return type

SymmGroup

distances()[source]

List containing the distances between the nodes. The fact that some node may not be reachable from another is represented by -1

Return type

List[List]

edges(color=False)[source]

Iterator over the edges of the graph

Return type

Generator

Parameters

color (Union[bool, int]) –

is_bipartite()[source]

True if the graph is bipartite

Return type

bool

is_connected()[source]

True if the graph is connected

Return type

bool

nodes()[source]

Iterator over the nodes of the graph

Return type

Generator