minimum cost for a linear graph (java)
<p>given a list of vertices (let's say 12)
and a list of edges that connect two vertices (bidirectional) you have a graph. let's say each and every vertex is connected to exactly three other vertices. is there an algorithm to find a linear sequence that minimizes the total cost of each edge?</p>

<p>for example given vertices 1-6 and the fact that:
vertex 1 is connected to vertices 6, 2, 5; vertex 2 is connected to vertices 1, 3, 4; vertex 3 is connected to vertices 4, 2, 6; vertex 4 is connected to vertices 5, 3, 2; vertex 5 is connected to vertices 4, 6, 1; and vertex 6 is connected to vertices 1, 5, 3; a linear sequence 651423 minimizes the distance at 17 (it costs 2 units from 1 to 6, 2 units from 1 to 2, 1 unit from 1 to 5, 1 unit from 2 to 3, ..., 5 units from 3 to 6, etc.)</p>

<p>given a list of vertices and the combinations between them, is there an algorithm for a linear sequence that minimizes the cost between vertices?</p>

<p>java code is preferred.</p>
