Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to change the Head of b (a NeighborhoodGraph) from Graph into List but Apply seems to fail. I start with a list of connected vertices:


I calculate the neighborhood graph of node 3. Its Head is Graph:

(* ==> Graph *)

I use Apply to change the Head to List:


However, the Head of c is still Graph:

(* ==> Graph *)

My real question is how to access the list of edges in a NeighborhoodGraph.

share|improve this question
As Graph[] is an atomic object, you cannot use Apply[] to extract the edges; instead, look up EdgeList[]. – J. M. Jun 3 '13 at 18:23
Thanks! EdgeList seems to be very well hidden. I could not find it under See Also in Graph, NeighborhoodGraph SubGraph, nor in GraphConstruction, guide/GraphModifications... Which makes me especially grateful that you pointed it to me. – Themis Jun 3 '13 at 19:18
It can be found on the Graph Representation and Properties guide page, a link to which can be found on the bottom of the Graph help page in the "Related guides" section. So, it wasn't really that far away. – Sjoerd C. de Vries Jun 3 '13 at 21:35

Apply does not work on Graph objects because they are atomic (you can verify this using AtomQ).

You can use EdgeList to retrieve the edge list of any graph.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.