Introduction by Example¶
We will briefly introduce the fundamental concepts of ControlPyEmb through self-contained examples.
Computing Embeddings¶
1from ControlPyEmb.ctrl import get_ctrl_emb
2import networkx as nx
3import numpy as np
4
5g1 = nx.fast_gnp_random_graph(50, 0.1) # generate a sparse random graph
6emb1 = list(get_ctrl_emb(g1).values()) ### get_ctrl_emb returns a dictionary containing the metrics with their corresponding values
7
8g2 = nx.fast_gnp_random_graph(50, 0.8) # generate a dense random graph
9emb2 = list(get_ctrl_emb(g2).values()) # extract embedding
10
11np.linalg.norm(np.array(emb1)-np.array(emb2)) ### compare the two embeddings