Hi,
I have two graphs that represent SQL tables :
f = star_graph(5)
nodelabel = ["T1","C1","C2","C3","C4"]
h = star_graph(4)
nodelabel = ["T2","C1.2","C2.2","C3.2"]
I want to context both graphs on “C2” and “C3.2” how do I do that in lightgraph?
Do you want the resulting graph to have C2 and C3.2 be the same vertex, or have an edge between them in their union? To create the combined graph, you can use blockdiag
, and then slightly adjust the resulting graph.
hi,
I want an edge between C2 & C3.2. I will check out blockdiag!
thanks!
EDIT:
I tried this function but now got a gplot with the two graphs in one picture but they are not unioned. I tried the join function which joins the whole two graphs to eachother?
The other challenge is how can I merge the nodelabels of both so I clearly see which graph is which?
Thanks in advance!
best,
If you do blockdiag(f, h)
, the vertices and edges of h
are appended to those of f
, preserving their order, so you can also append (vcat
) the vectors of node labels, e.g.
f = star_graph(5)
f_nodelabel = ["T1","C1","C2","C3","C4"]
h = star_graph(4)
h_nodelabel = ["T2","C1.2","C2.2","C3.2"]
fh = blockdiag(f, h)
fh_nodelabel = [f_nodelabel; h_nodelabel]
To join the graphs through C2 and C3.2 (the third node of the f
and the fourth of h
), this is an option:
add_edge!(fh, 3, nv(f)+4)
1 Like
Ah, so blockdiag
merges two seperate graphs into one disjointed graph and from there you can start adding edges. Thank you!