Search in sources :

Example 11 with DirectedEdge

use of com.revolsys.geometry.planargraph.DirectedEdge in project com.revolsys.open by revolsys.

the class MiscellaneousTest2 method testDirectedEdgeComparator.

public void testDirectedEdgeComparator() {
    final DirectedEdge d1 = new DirectedEdge(new Node(0, 0), new Node(10, 10), new PointDoubleXY(10, 10), true);
    final DirectedEdge d2 = new DirectedEdge(new Node(0, 0), new Node(20, 20), new PointDoubleXY(20, 20), false);
    assertEquals(0, d2.compareTo(d1));
}
Also used : DirectedEdge(com.revolsys.geometry.planargraph.DirectedEdge) Node(com.revolsys.geometry.planargraph.Node) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 12 with DirectedEdge

use of com.revolsys.geometry.planargraph.DirectedEdge in project com.revolsys.open by revolsys.

the class MiscellaneousTest2 method testDirectedEdgeToEdges.

public void testDirectedEdgeToEdges() {
    final DirectedEdge d1 = new DirectedEdge(new Node(0, 0), new Node(10, 10), new PointDoubleXY(10, 10), true);
    final DirectedEdge d2 = new DirectedEdge(new Node(20, 0), new Node(20, 10), new PointDoubleXY(20, 10), false);
    final List edges = DirectedEdge.toEdges(Arrays.asList(d1, d2));
    assertEquals(2, edges.size());
    assertNull(edges.get(0));
    assertNull(edges.get(1));
}
Also used : DirectedEdge(com.revolsys.geometry.planargraph.DirectedEdge) Node(com.revolsys.geometry.planargraph.Node) List(java.util.List) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 13 with DirectedEdge

use of com.revolsys.geometry.planargraph.DirectedEdge in project com.revolsys.open by revolsys.

the class ConnectedSubgraphFinder method addEdges.

/**
 * Adds the argument node and all its out edges to the subgraph.
 * @param node the node to add
 * @param nodeStack the current set of nodes being traversed
 */
private void addEdges(final Node node, final Stack nodeStack, final Subgraph subgraph) {
    node.setVisited(true);
    for (final Object element : node.getOutEdges()) {
        final DirectedEdge de = (DirectedEdge) element;
        subgraph.add(de.getEdge());
        final Node toNode = de.getToNode();
        if (!toNode.isVisited()) {
            nodeStack.push(toNode);
        }
    }
}
Also used : DirectedEdge(com.revolsys.geometry.planargraph.DirectedEdge) Node(com.revolsys.geometry.planargraph.Node)

Aggregations

DirectedEdge (com.revolsys.geometry.planargraph.DirectedEdge)13 Node (com.revolsys.geometry.planargraph.Node)9 LineString (com.revolsys.geometry.model.LineString)3 Point (com.revolsys.geometry.model.Point)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 ListIterator (java.util.ListIterator)3 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)2 Edge (com.revolsys.geometry.planargraph.Edge)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 PointList (com.revolsys.geometry.model.PointList)1