Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to define a graph using Cartesian coordinates

I am trying to figure out (1) how to input a graph into Sage where the vertices are described as Cartesian coordinates (3-tuples), and then (2) for each pair of vertices, compute the Euclidean distance between the two and, if the Euclidean distance is some fixed value $d$, add an edge between these two vertices.

Specifically, here are my questions:

  1. How do I nput a graph into Sage where the vertices are described as Cartesian coordinates (3-tuples)?
  2. Is there a pre-defined function in Sage for computing the Euclidean distance between two Cartesian coordinates?

How to define a graph using Cartesian coordinates

I am trying to figure out (1) how to input a graph into Sage where the vertices are described as Cartesian coordinates (3-tuples), and then (2) for each pair of vertices, compute the Euclidean distance between the two and, if the Euclidean distance is some fixed value $d$, add an edge between these two vertices.

Specifically, here are my questions:

  1. How do I nput input a graph into Sage where the vertices are described as Cartesian coordinates (3-tuples)?
  2. Is there a pre-defined function in Sage for computing the Euclidean distance between two Cartesian coordinates?