Skip to content
Snippets Groups Projects
Commit f9930b7f authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Add script to draw the graph of trajectories

parent 9811eb6c
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
from graph_tool import draw
import graph_tool
import sys
import pygraphviz as pgv
import json
g = graph_tool.load_graph(sys.argv[1])
G = pgv.AGraph(directed = True)
for v in g.vertices():
G.add_node(g.vp.name[v])
for e in g.edges():
source = e.source()
target = e.target()
G.add_edge(g.vp.name[source], g.vp.name[target],
penwidth = 10 / g.ep.cost_function[e])
with open("traj_segm.json") as f: traj_segm = json.load(f)
for segment_list in traj_segm:
for i in range(len(segment_list) - 1):
e = G.get_edge(segment_list[i], segment_list[i + 1])
e.attr["color"] = "red"
G.write(sys.argv[2])
G.close()
# strange failure of the script without this, except in ipython:
# TypeError: 'NoneType' object is not callable
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment