-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraphitty_csv.py
More file actions
executable file
·55 lines (42 loc) · 1.17 KB
/
graphitty_csv.py
File metadata and controls
executable file
·55 lines (42 loc) · 1.17 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
"""
Script for consuming given file into output image
graphitty_csv csv1 csv1 combine_output.png
"""
import sys
import pandas as pd
from graphitty.graphitty import Graphitty
from graphitty.combiner import GraphCombiner
from nxpd import draw
def parse_graph(csv):
output_png = csv + '.png'
df = pd.read_csv(csv)
g = Graphitty(
df,
id_col='ip',
beahivour_col='url',
ts_col='date')
# draw non-condensed version
nx_orig = g.render_graph(
filter_subgraph=False
)
draw_with_output(nx_orig, "original_" + output_png)
g_simplify = g.simplify()
nx_orig = g_simplify.render_graph(
filter_subgraph=True
)
draw_with_output(nx_orig, "simplified_" + output_png)
return g
def draw_with_output(g, f):
print "Drawing: {}".format(f)
draw(g, f, show=False)
if __name__ == '__main__':
csv1 = sys.argv[1]
csv2 = sys.argv[2]
imgout = sys.argv[3]
g1 = parse_graph(csv1)
g2 = parse_graph(csv2)
g = GraphCombiner(g1, g2)
simplified_g = g.get_simplifed_combine_graph()
nx_combined = simplified_g.render_graph()
draw_with_output(nx_combined, imgout)