# GraphPlot3D: How to plot undirected graph with a list of edges?

I have a list of edges defined based on vertices like this:

Edges={{2, 1}, {10, 9}, {11, 10}, {11, 4}, {17, 12},.....}
(*Where each number is the index of a vertex which has 3D coordinates*)


In order to plot a graph I first made Edges looks like this (I want to plot undirected graph)

edges = Flatten[Table[{Edges[[i, 1]] <-> Edges[[i, 2]]}, {i, 1, Length[Edges]}]];


Then I plot the graph

GraphPlot3D[edges, VertexLabeling -> False, (*VertexCoordinateRules -> nodescoord*), \BoxRatios -> Automatic,ViewPoint -> {0, 0, -Infinity}];


Where am I wrong? Is it the way I define edges using "<->"?

Use Graph[] instead of GraphPlot[]

n = 8;
vC = RandomReal[{0, 1}, {n, 3}];
edges = UndirectedEdge @@@ Subsets[Range@n, {2}];
Graph[edges, VertexCoordinates -> vC]


• @ belisarius，Thanks, I thought graph can only display 2D images. But why VertexLabels -> "Name" property fails. And, is there a place to share mine and use Mathematica extension packages written by others? Commented Dec 23, 2013 at 5:58
• @novice You can talk about that in chat chat.stackexchange.com Commented Dec 23, 2013 at 6:16

Is it the way I define edges using "<->"?

Yes. If we use -> (Rule) instead of <-> ,GraphPlot3D works as expected.

SeedRandom[123]
n = 20;
edges = RandomChoice[Subsets[Range@n, {2}], 20];
edgelist = Rule @@@ edges;
coords = RandomReal[{0, 1}, {n, 3}];
GraphPlot3D[edgelist,
VertexCoordinateRules -> Thread[Range[n] -> coords], Boxed -> False,
ImageSize -> 600, EdgeRenderingFunction -> (Tube[#1, .02] &),
ViewPoint -> {0, 0, -Infinity},
VertexRenderingFunction ->
({ColorData["Atoms"][RandomInteger[{1, 117}]], Sphere[#1, .04]} &),
PlotStyle -> Directive[Specularity[White, 20]]]