Mathematica > Mathematics and Algorithms > Graphs & Networks > Graph Predicates and Properties > EdgeQ >
Mathematica > Visualization and Graphics > Graphs & Networks > Graph Predicates and Properties > EdgeQ >

EdgeQ

EdgeQ
yields True if e is an edge in the graph g and False otherwise.
Test whether undirected edges are part of a graph:
Test directed edges:
Test whether undirected edges are part of a graph:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
 
Test directed edges:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
EdgeQ works with undirected graphs:
Directed graphs:
EdgeQ returns False for items that are not edge expressions:
Rules can be used to test for directed edges:
When g is not a graph, EdgeQ evaluates to False:
Verify that g is not a graph using GraphQ:
EdgeQ works with large graphs:
Compare performance with a test based on EdgeList:
Test whether is adjacent to :
Check input to a function:
Take correct action depending on whether an item is an edge or a vertex:
Act on an edge:
Act on a vertex:
EdgeQ is equivalent to MemberQ[EdgeList[g], uDirectedEdgev]:
The performance of EdgeQ is typically higher:
EdgeQ is equivalent to MemberQ[EdgeList[g], uUndirectedEdgev|vUndirectedEdgeu]:
The performance of EdgeQ is typically higher:
Use EdgeIndex to find the position of an edge in EdgeList[g]:
EdgeIndex is typically faster than Position:
Use VertexQ to test whether a vertex is part of a graph:
Some edges do not seem to be recognized:
Membership is tested using SameQ rather than Equal:
By using identical expressions it can still be tested:
New in 8
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF