# Displaying Points and Lines in 3D

I'm trying to roll my own graph visualization, and to do that, I need a 3D plot of a graph.

I have the following code for generating points and edges:

vertices = Table[{RandomReal[], RandomReal[], RandomReal[]}, 20]
edges = Table[{RandomInteger[{1, Length[vertices]}],
RandomInteger[{1, Length[vertices]}]}, 40]


This here code runs just fine to display the points:

Graphics3D[
Map[Point, vertices]
]


and this code generates a list of lines:

lines = Map[
Function[e, Line[
Part[vertices, Part[e, 1]],
Part[vertices, Part[e, 2]]]],
edges
]


My question now is this: How do I add the lines to the 3D graphic? I tried

Graphics3D[{
Map[Point, vertices],
lines
}]

• You need Line[{pt1, pt2}], not Line[pt1, pt2]. Also, consider this: Graphics3D[ GraphicsComplex[vertices, {Point@Length@vertices, Line@edges}]]. – Kuba Jan 10 at 11:52
• Thanks, that worked. – Joshua Moore Jan 10 at 12:00