src.graph package

Submodules

src.graph.Graph module

class src.graph.Graph.Graph(adj_matrix: ndarray, directed: bool = False, features: ndarray = None, labels: ndarray = None, dataset_name: ndarray = '')[source]

Bases: object

Graph class to represent a graph using the adjacency matrix and features

Parameters:
  • adj_matrix (np.ndarray) – Adjacency matrix of the graph of shape (n, n) where n is the number of nodes in the graph

  • features (np.ndarray) – Features of the nodes in the graph of shape (n, f) where f is the number of features per node

  • labels (np.ndarray) – Labels of the nodes in the graph of shape (n,) where n is the number of nodes in the graph

  • directed (bool) – Boolean flag to indicate if the graph is directed or undirected

  • dataset_name (str) – Name of the dataset (if possible)

draw(clusters: list[int] = None, draw_labels: bool = False) None[source]

Draws the graph using the NetworkX draw method. If clusters are provided, the nodes are colored based on the clusters based on https://stackoverflow.com/questions/8389636/creating-over-20-unique-legend-colors-using-matplotlib

Parameters:
  • clusters (list[int]) – List of cluster labels for each node

  • draw_labels (bool) – Boolean flag to indicate if the labels should be drawn

Module contents