Skip to content

Commit

Permalink
graph class
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelja committed Dec 18, 2018
1 parent 2751882 commit 3b400aa
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions enron/graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import matplotlib.pyplot as plt
import networkx as nx


class Graph():
def __init__(self, persons, connections):
self.persons = persons
self.connections = connections
print('init')

def draw_graph(self):
g = nx.Graph()

persons = list(self.persons)
for connection in self.connections:
emails = connection[0].split(';')
g.add_edge(emails[0], emails[1])

pos = nx.circular_layout(g)
nx.draw_networkx_nodes(g, pos,
nodelist=persons,
node_color='r',
node_size=2000,
alpha=0.6)
nx.draw_networkx_edges(g, pos, width=1.0, alpha=0.5)
plt.axis('off')
plt.show()

0 comments on commit 3b400aa

Please sign in to comment.