2
$\begingroup$
Graph[{1, 2, 3, 4, 5, 6}, {1 -> 2, 1 -> 3, 2 -> 5, 2 -> 6, 5 -> 6}, 
 VertexLabeling -> True]
Graph::optx: Unknown option VertexLabeling in Graph[{1,2,3,4,5,6},{1->2,1->3,2->5,2->6,5->6},VertexLabeling->True].
GraphPlot[{1, 2, 3, 4, 5, 6}, {1 -> 2, 1 -> 3, 2 -> 5, 2 -> 6, 
  5 -> 6}, VertexLabeling -> True]
GraphPlot::argx: GraphPlot called with 2 arguments; 1 argument is expected. >>

This was the message came after trying to draw the graph.

$\endgroup$
3
  • 1
    $\begingroup$ VertexLabeling works with GraphPlot, but not with Graph. GraphPlot only expects one argument. If you drop the $\{1,2,3,4,5,6\}$ then the GraphPlot command works. $\endgroup$ – almagest May 24 '16 at 11:44
  • $\begingroup$ But that will give only the dots right, I need a graph with edges as well as isolated vertices also. $\endgroup$ – Ashwin Koodathil May 24 '16 at 11:48
  • $\begingroup$ GraphPlot[{1 -> 2, 1 -> 3, 2 -> 5, 2 -> 6, 5 -> 6}, VertexLabeling -> True] gives dots and edges. $\endgroup$ – almagest May 24 '16 at 11:48
1
$\begingroup$

Seems in Mathematica 10 you should use the VertexLabels option. So, your code can be written like this:

Graph[{1, 2, 3, 4, 5, 6}, {1 -> 2, 1 -> 3, 2 -> 5, 2 -> 6, 5 -> 6}, 
 VertexLabels -> "Name"]

Which will give the result shown below:

enter image description here

$\endgroup$
0
$\begingroup$

Just to illustrate some ways to motivate play:

{v, e} = {{1, 2, 3, 4, 5, 6}, {1 -> 2, 1 -> 3, 2 -> 5, 2 -> 6, 
    5 -> 6}};
GraphPlot[e, VertexLabeling -> All]
Graph[v, e, VertexLabels -> Placed["Name", Center], 
 VertexStyle -> LightBlue, VertexSize -> 0.6]
GraphPlot[e, 
 VertexRenderingFunction -> (Text[
     Framed[Style[#2, Red], Background -> White], #1] &)]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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