StaticGraph

class stgraph.graph.StaticGraph(edge_list: list, edge_weights: list, num_nodes: int)[source]

Bases: STGraphBase

Represent Static graphs in STGraph.

This abstract class outlines the interface for defining a static graphs used in STGraph. As of now the static graph is implemented using the Compressed Sparse Row (CSR) format.

Example:

from stgraph.graph import StaticGraph
from stgraph.dataset import HungaryCPDataLoader

hungary = HungaryCPDataLoader()

graph = StaticGraph(
    edge_list = hungary.get_edges(),
    edge_weights = hungary.get_edge_weights(),
    num_nodes = hungary.gdata["num_nodes"]
)
get_ndata(field: any) any[source]

Return the graph metadata.

get_num_edges() int[source]

Return the number of edges in the static graph.

get_num_nodes() int[source]

Return the number of nodes in the static graph.

graph_type() str[source]

Return the graph type.

in_degrees() ndarray[source]

Return the graph inwards node degree array.

out_degrees() ndarray[source]

Return the graph outwards node degree array.

set_ndata(field: str, val: any) None[source]

Set the graph metadata.

weighted_in_degrees() ndarray[source]

weighted_in_degrees.