Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw graph with disjoint edges?

I have adjacency matrix for graph. I need to vizualize this graph without intersecting edges. Vertex in the graph can be arranged randomly. I know one solution - enumeration of all edges for intersections. If the edges intersect, then rearrange the vertex, but it's too expensive for a large number of vertexes (more than 20). Any other ideas how to check for intersecting edges?

like image 483
mindw0rk Avatar asked Nov 11 '22 08:11

mindw0rk


1 Answers

It's really easy to visualise any graph in a 3D plane with disjoint edges.

1) Place all the vertices in any point in the 3D plane such that no three vertices are collinear and no four vertices are in same plane.

2) Traverse through the adjacency matrix and draw a line/curve to connect the vertices.

In a 2D plane it's not guaranteed for the existence of a solution. For example take the worst case scenario that there are some 10 vertices and every vertex is connected to each other.

like image 120
cegprakash Avatar answered Nov 15 '22 08:11

cegprakash