| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
package net.sourceforge.combean.adapters.drasys.graph; |
| 23 | |
|
| 24 | |
import drasys.or.graph.AddEdgeI; |
| 25 | |
import drasys.or.graph.AddVertexI; |
| 26 | |
import drasys.or.graph.DuplicateEdgeException; |
| 27 | |
import drasys.or.graph.DuplicateVertexException; |
| 28 | |
import drasys.or.graph.GraphI; |
| 29 | |
import drasys.or.graph.VertexNotFoundException; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | 0 | public class DRAGraphUtils { |
| 36 | |
|
| 37 | |
public static void addNumberedVertices(AddVertexI g, int from, int to) |
| 38 | |
throws DuplicateVertexException { |
| 39 | 189 | for (int i = from; i <= to; i++) { |
| 40 | 150 | g.addVertex(new Integer(i)); |
| 41 | |
} |
| 42 | 39 | } |
| 43 | |
|
| 44 | |
public static void addNumberedPath(AddEdgeI g, int[] path, |
| 45 | |
boolean isDirected) |
| 46 | |
throws DuplicateEdgeException, VertexNotFoundException { |
| 47 | 21 | for (int i = 0; i < path.length-1; i++) { |
| 48 | 15 | g.addEdge(new Integer(path[i]), new Integer(path[i+1]), |
| 49 | |
null, isDirected); |
| 50 | |
} |
| 51 | 6 | } |
| 52 | |
|
| 53 | |
public static void addNumberedPath(AddEdgeI g, int from, int to, |
| 54 | |
boolean isDirected) |
| 55 | |
throws DuplicateEdgeException, VertexNotFoundException { |
| 56 | 3 | int[] path = new int[to-from+1]; |
| 57 | 12 | for (int i = from; i <= to; i++) { |
| 58 | 9 | path[i-from] = i; |
| 59 | |
} |
| 60 | 3 | addNumberedPath(g, path, isDirected); |
| 61 | 3 | } |
| 62 | |
|
| 63 | |
public static void addNumberedCycle(AddEdgeI g, int from, int to, |
| 64 | |
boolean isDirected) |
| 65 | |
throws DuplicateEdgeException, VertexNotFoundException { |
| 66 | 0 | addNumberedPath(g, from, to, isDirected); |
| 67 | 0 | g.addEdge(new Integer(to), new Integer(from), null, isDirected); |
| 68 | 0 | } |
| 69 | |
|
| 70 | |
public static DRAGraphVertexAsNode getVertexByNumber(GraphI g, int vertexNum) { |
| 71 | 0 | return new DRAGraphVertexAsNode(g.getVertex(new Integer(vertexNum))); |
| 72 | |
} |
| 73 | |
} |