# Check Presence of Specified Edges in Graph

1 view (last 30 days)
Kamal Premaratne on 23 Oct 2021
Commented: Kamal Premaratne on 29 Oct 2021
I have a digraph G. I also have another digraph H. I want to check whether the edges in H are present in G and highlight those edge that are in common. The command
> findedge(G, H.Edges.Endnodes(:, 1), H.Edges.Endnodes(:, 2))
does not work because it gives an error as soon as an edge in H is absent in G.
Thank you so much.
Kamal
##### 2 CommentsShowHide 1 older comment
Kamal Premaratne on 29 Oct 2021
Thank you Steven.
-- No, G and H may not have the same set of nodes.
-- If G has a node named "Alice" and H also has a node named "Alice", then yes, both are the same.
-- Perhaps it is better if I mention the particular dataset that I am working with.
C = digraph representing C elegance (https://wormwiring.org/pages/software.html).
G = a particular subgraph of C (which I generate via a spectral clutering algorithm).
H = Navigation circuit of C [Gray2005PNAS].
My main objective is to determine how much of the Nav circuit in H is captured in the subgraph G. The problem is that each node in H is a "proxy" for a set of nodes. For instace, node "AIB" in C is a proxy for both "AIBL" and "AIBR" that appear in C. So, an edge in H becomes a proxy for a set of edges in C. For instance, take the edge AIB > AIA in H. AIB is a proxy for AIBL and AIBR. Similarly, AIA is a proxy for AIAL and AIAR. So, the edge AIB > AIA in H is a proxy for 4 edges in C. Does G contain all 4, only some of the 4, or none of these 4 edges? That's what I want to find out.
Thank you so much.
Kamal
[Gray2005PNAS] Gray, Hill, Bargmann (2005). A circuit for navigation in Caenorhabditis elegans. PNAS 102(9) 3184–3191.

Shanmukha Voggu on 26 Oct 2021
Hi Kamal,
There is an error in the command that you provided, please change "Endnodes" to "EndNodes", This will resolve the error hopefully.
The correct command is:
findedge(G, H.Edges.EndNodes(:, 1), H.Edges.EndNodes(:, 2));
Hope this helps!
Kamal Premaratne on 28 Oct 2021
Thank you Shanmuka for pointing out the typo (it should be "EndNodes" and not Endnodes").
But, this does not resolve the problem. If any edge in H that is specified through H's EndNodes table is absent in G, MATLAB spits out an error.