Re: [graph-tool] Graphs into layers

2020-12-15 Thread Tiago de Paula Peixoto

Am 14.12.20 um 06:49 schrieb Lietz, Haiko:

Is there a better way?


Yes, take a look at the graph_union() function, with joins two graphs 
into one. If you pass it an 'intersection' parameter, it maps nodes of 
one graph into the other, which allows you to join only the edge lists.



I’m using gt 2.29 from conda-ostrokach.


Please upgrade! There has been up-to-date graph-tool packages in 
conda-forge for a while now.


Best,
Tiago

--
Tiago de Paula Peixoto 


OpenPGP_0x612DEFB798507F25.asc
Description: application/pgp-keys


OpenPGP_signature
Description: OpenPGP digital signature
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


[graph-tool] Graphs into layers

2020-12-13 Thread Lietz, Haiko
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