Hi all,

If I have two graphs g and h with internal edge property maps, how can I make 
these the layers of a graph i?

g = Graph(directed=False)
g.add_vertex(4)
g_weight = g.new_ep('int')
g_layer = g.new_ep('int')
g.add_edge_list([[0, 1, 2, 0], [2, 3, 2, 0]], eprops=[g_weight, g_layer])
g.edge_properties['weight'] = g_weight
g.edge_properties['layer'] = g_layer

h = Graph(directed=False)
h.add_vertex(4)
h_weight = h.new_ep('int')
h_layer = h.new_ep('int')
h.add_edge_list([[1, 2, 1, 1]], eprops=[h_weight, h_layer])
h.edge_properties['weight'] = h_weight
h.edge_properties['layer'] = h_layer

This works but is not nice and gets lengthy when layers are many:

i = g.copy() # make deep copy
i.add_edge_list(h.edges()) # this does not add the edge properties
i.ep.weight.a[-h.num_edges():] = h.ep.weight.a # manually add the edge weight
i.ep.layer.a[-h.num_edges():] = h.ep.weight.a # manually add the edge layer

Is there a better way?

I'm using gt 2.29 from conda-ostrokach.

Many thanks

Haiko

_______________________________________________
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to