Hi,
I am trying to create a simple NxM graph where each vertex is connected to
all of its immediate neighbors with directed edges. When I use graph_draw to
see the graph it crashes if I define the graph to be directed, but works
fine when the graph is not.
Interestingly enough, the problem seems to disappear for very small size
graphs (e.g. 5x5)
I am using version 2.26 on an Ubuntu 16.04 system. See bellow a snippet of
code that recreates the problem.
Thanks,
Vaggelis
import gi
gi.require_version('Gtk', '3.0')
from graph_tool.all import *
if __name__ == '__main__':
dt_dict = {}
g = Graph(directed=False)
dict_v_name_to_v = {}
g.vertex_properties["name"] = g.new_vertex_property("string")
g.vertex_properties["pos"] = g.new_vertex_property("vector<double>")
g.vertex_properties["coords"] =
g.new_vertex_property("vector<double>")
vp = g.vertex_properties
ep = g.edge_properties
N_LAT = 20
N_LON = 20
# Vertices
for i in range(0, N_LAT):
for j in range(0, N_LON):
v_name = str(i) + '_' + str(j)
v = g.add_vertex()
dict_v_name_to_v[v_name] = v
vp["name"][v] = v_name
vp['pos'][v] = [float(i), float(j)]
# vp['coords'][v] = (lat_ar[i], lng_ar[j])
# vp['elev_in_m'][v] = el_ar[i, j]
# Edges
for j in range(1, N_LON - 1): # long
jm1 = j - 1
jp1 = j + 1
for i in range(1, N_LAT - 1): # lat
ip1 = i + 1
im1 = i - 1
print(str((i, j)))
v_i_jm1 = dict_v_name_to_v[str(i) + '_' + str(jm1)]
v_i_j = dict_v_name_to_v[str(i) + '_' + str(j)]
v_i_jp1 = dict_v_name_to_v[str(i) + '_' + str(jp1)]
v_ip1_jm1 = dict_v_name_to_v[str(ip1) + '_' + str(jm1)]
v_ip1_j = dict_v_name_to_v[str(ip1) + '_' + str(j)]
v_ip1_jp1 = dict_v_name_to_v[str(ip1) + '_' + str(jp1)]
v_im1_jm1 = dict_v_name_to_v[str(im1) + '_' + str(jm1)]
v_im1_j = dict_v_name_to_v[str(im1) + '_' + str(j)]
v_im1_jp1 = dict_v_name_to_v[str(im1) + '_' + str(jp1)]
e_i_jm1 = g.add_edge(v_i_j, v_i_jm1)
e_i_jp1 = g.add_edge(v_i_j, v_i_jp1)
e_ip1_jm1 = g.add_edge(v_i_j, v_ip1_jm1)
e_ip1_j = g.add_edge(v_i_j, v_ip1_j)
e_ip1_jp1 = g.add_edge(v_i_j, v_ip1_jp1)
e_im1_jm1 = g.add_edge(v_i_j, v_im1_jm1)
e_im1_j = g.add_edge(v_i_j, v_im1_j)
e_im1_jp1 = g.add_edge(v_i_j, v_im1_jp1)
graph_draw(g,
pos=g.vertex_properties['pos'],
# vertex_text=g.vertex_properties["name"],
update_layout=False)