Message Boards Message Boards

0
|
4471 Views
|
8 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Why GraphPlot uses \[Rule] for edges in place of \[DirectedEdge] ?

I cannot GraphPlot edges defined via [DirectedEdge]. It seems quite confusing to me. Perhaps some goes wrong in my Matematica installation?

8 Replies
Posted 9 years ago

The documentation page for GraphPlot seems to show that it uses Rule to identify edges. It also seems to show that each Rule indicates an edge in one direction. Thus if you want an undirected edge you give one rule for each direction. Does this work for you?

GraphPlot[{1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2}, DirectedEdges -> True, VertexLabeling -> True]

graph plot

Click on the Details and Options on the documentation page to see more information on how to use GraphPlot.

POSTED BY: Bill Simpson

Dear Bill, thank you for your reply. Please see the attached Notebook Best

Attachments:
Posted 9 years ago

GraphPlot[Graph@edgeList3] if you want to use DirectedEdge.

POSTED BY: Bill Simpson

Thank you Bill. I am a mathematician. I like the neatness of Mathematica in handling formulas and data structures. For GraphPlot a list of rules being a graph is confusing! Moreover, Graph[ {list of rules}] results in a graph is a mess!? What is your opinion?

Posted 9 years ago

Hi Flavio, What sort of problem are you having? Perhaps you could post some code? You can find out how to do that and much more here How to post

In[7]:= edges = {DirectedEdge[a, b], UndirectedEdge[b, c], 
  DirectedEdge[c, a]}

Out[7]= {a \[DirectedEdge] b, b <-> c, c \[DirectedEdge] a}

In[8]:= GraphPlot[Graph@edges, DirectedEdges -> True]

enter image description here

POSTED BY: David Keith

Dear David, thank you for your reply. See the attached Notebook Best

Attachments:
Posted 9 years ago

I think I see the problem, Flavio. This is not well documented, but apparently GraphPlot will plot a graph either from a list of rules, or from a Graph object. Your edgeList4 is a list of rules, so GraphPlot will plot it. However, your edgeList3 is a list of edges. It needs to be made into a Graph object -- Graph[edgeList3] -- before it can be passed to GraphPlot.

Best, David

POSTED BY: David Keith

Thank you David. I think this is confusing. It upsets Mathematica clearness. Best, Flavio

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract