-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraphdisplay.py
More file actions
33 lines (31 loc) · 1.22 KB
/
graphdisplay.py
File metadata and controls
33 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import motifs
import numpy as np
def renderDiGraphFromAdj(adjMat):
graph = nx.DiGraph(adjMat)
#pos = nx.circular_layout(graph)
#pos = nx.spectral_layout(graph)
pos = nx.shell_layout(graph)
#nx.draw(graph, cmap = plt.get_cmap('jet'))
nx.draw_networkx_nodes(graph, pos, nodelist=graph.nodes, ax=None, node_size=400)
nx.draw_networkx_edges(graph, pos, edgelist=graph.edges, width=1.0, alpha=0.5)
labels = {}
for index in range(0, len(adjMat)):
labels[index] = str(index)
nx.draw_networkx_labels(graph, pos, labels)
def renderUndirGraphFromAdj(adjMat):
graph = nx.Graph(adjMat)
#pos = nx.spring_layout(graph, k=400)
#pos = nx.shell_layout(graph)
#pos = nx.spectral_layout(graph)
pos = nx.circular_layout(graph)
#nx.draw(graph, cmap = plt.get_cmap('jet'))
#nx.draw_networkx_nodes(graph, pos, nodelist=graph.nodes, node_size=np.empty(len(graph.nodes)).fill(50))
nx.draw_networkx_nodes(graph, pos, nodelist=graph.nodes, node_size=400)
nx.draw_networkx_edges(graph, pos, edgelist=graph.edges, width=1.0, alpha=0.5)
labels = {}
for index in range(0, len(adjMat)):
labels[index] = str(index)
nx.draw_networkx_labels(graph, pos, labels)