0
$\begingroup$

If I have the coordinates p1={{1,1,1}},p2={{1,1,2},{1,2,1},{2,1,1}},then I use code the following to link them with the centre of p1[[1]].

p1={{1,1,1}};
p2={{1,1,2},{1,2,1},{2,1,1}};
Graph3D[
    Table[
     UndirectedEdge[p1[[1]], p2[[i]]], {i, Length[p2]}]]

At last all points linked to the p1[[1]] but they ignore the space positions of their coordinates, all the points are in the same plane.

Can anyone give me the advice of how to generate the 3d Graph, meanwhile hold their space positions.I only want the graph, because, the vertexdegree can be counted later.

$\endgroup$
2
  • $\begingroup$ This is what you want Graphics3D[Table[Line[{p1[[1]], p2[[i]]}], {i, Length[p2]}], Boxed -> False]? $\endgroup$
    – yode
    Jul 25, 2017 at 17:09
  • $\begingroup$ @yode, Yes you r right, but actually it is the graphics3D giving the similar visual plot, but what I expect to have is the graph that can be analysed under the mathematical way. $\endgroup$
    – 吴剑涛
    Jul 26, 2017 at 13:36

1 Answer 1

4
$\begingroup$

What you are doing is using the 3D coordinates to indicate the vertices, but Graph and Graph3D won't automatically use these for the embedding. It's easiest to just use integers for the vertices,

p1 = {{1, 1, 1}};
p2 = {{1, 1, 2}, {1, 2, 1}, {2, 1, 1}};
Graph3D[
 Thread[1 <-> {2, 3, 4}],
 VertexCoordinates -> Join[p1, p2]
 ]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you very much your approach!!! Now I got known of your code and the some basic of how mathematica work. $\endgroup$
    – 吴剑涛
    Jul 26, 2017 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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