netket.graph.Graph#

class netket.graph.Graph#

Bases: netket.graph.AbstractGraph

A simple implementation of Graph based on an external graph library.

The underlying implementation is based on igraph and supports conversion to networkx, but this is an implementation detail and could be changed in the future.

Inheritance
Inheritance diagram of netket.graph.Graph
__init__(edges, n_nodes=None)[source]#

Construct the a graph starting from a list of edges and optionally a given number of nodes.

Parameters
Attributes
edge_colors#

Sequence of edge colors, in the order of the edges returned by self.edges.

Return type

Sequence[int]

n_edges#

The number of edges in the graph.

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

PermutationGroup

distances()[source]#

List containing the distances between the nodes. The distance between unconnected nodes (no path exists between them) is set to -1

Return type

List[List]

edges(color=None, *, return_color=False, filter_color=None)[source]#

Returns the sequence of edges of the graph.

Parameters
  • return_color (bool) – If True, return edges with added color information.

  • filter_color (Optional[int]) – If set, return only edges of the given color.

Return type

Union[Sequence[Tuple[int, int]], Sequence[Tuple[int, int, int]]]

Returns

A sequence of edges as tuples (i, j) or, if return_color is passed, a sequence of tuples (i, j, c) with c indicating the color of the respective edge.

classmethod from_igraph(graph)[source]#

Creates a new Graph instance from an igraph.Graph instance.

Return type

Graph

Parameters

graph (igraph.Graph) –

classmethod from_networkx(graph)[source]#

Creates a new Graph instance from a networkx graph.

Return type

Graph

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

Sequence[int]

to_igraph()[source]#

Returns a copy of this graph as an igraph.Graph instance.

to_networkx()[source]#

Returns a copy of this graph as an igraph.Graph instance. This method requires networkx to be installed.