STAG Python  1.2.1
Spectral Toolkit of Algorithms for Graphs
Loading...
Searching...
No Matches
stag.graph Namespace Reference

Classes

class  AdjacencyListLocalGraph
 A local graph backed by an adjacency list file on disk. More...
 
class  Edge
 An object representing a weighted edge in a graph. More...
 
class  Graph
 The core object used to represent graphs for use with the library. More...
 
class  LocalGraph
 An abstract class which defines methods for exploring the local neighborhood of vertices in a graph. More...
 

Functions

Graph cycle_graph (n)
 Construct a cycle graph on n vertices.
 
Graph complete_graph (n)
 Construct a complete graph on n vertices.
 
Graph barbell_graph (n)
 Construct a barbell graph.
 
Graph star_graph (n)
 Construct a star graph.
 
def from_networkx (networkx.Graph netx_graph, str edge_weight_attribute="weight")
 Given a networkx graph, convert it to a stag.graph.Graph object.
 

Function Documentation

◆ cycle_graph()

Graph stag.graph.cycle_graph (   n)

Construct a cycle graph on n vertices.

Parameters
nthe number of vertices in the constructed graph
Returns
a stag.graph.Graph object representing a cycle graph

◆ complete_graph()

Graph stag.graph.complete_graph (   n)

Construct a complete graph on n vertices.

Parameters
nthe number of vertices in the constructed graph
Returns
a stag.graph.Graph object representing a complete graph

◆ barbell_graph()

Graph stag.graph.barbell_graph (   n)

Construct a barbell graph.

The barbell graph consists of 2 cliques on n vertices, connected by a single edge.

Parameters
nthe number of vertices in each of the two cliques. The returned graph will have \(2n\) vertices.
Returns
a stag.graph.Graph object representing the barbell graph

◆ star_graph()

Graph stag.graph.star_graph (   n)

Construct a star graph.

The star graph consists of one central vertex connected by an edge to n-1 outer vertices.

Parameters
nthe number of vertices in the constructed graph
Returns
a stag.graph.Graph object representing the star graph

◆ from_networkx()

def stag.graph.from_networkx ( networkx.Graph  netx_graph,
str   edge_weight_attribute = "weight" 
)

Given a networkx graph, convert it to a stag.graph.Graph object.

Unless otherwise specified, this method will use the 'weight' attribute on the networkx edges to assign the weight of the edges. If no such attribute is present, the edges will be added with weight \(1\).

Parameters
netx_graphThe networkx graph object to be converted.
edge_weight_attribute(default 'weight') the edge attribute to be used to generate the weights
Returns
A stag.graph.Graph object which is equivalent to the networkx graph.