createSubgraphs method

List createSubgraphs(
  1. PlanarGraph graph
)

Implementation

List createSubgraphs(PlanarGraph graph) {
  List subgraphList = [];
  for (Node node in graph.getNodes()) {
    if (!node.isVisited()) {
      BufferSubgraph subgraph = new BufferSubgraph();
      subgraph.create(node);
      subgraphList.add(subgraph);
    }
  }

  /**
   * Sort the subgraphs in descending order of their rightmost coordinate.
   * This ensures that when the Polygons for the subgraphs are built,
   * subgraphs for shells will have been built before the subgraphs for
   * any holes they contain.
   */
  subgraphList.sort(
      (o1, o2) => (o1 as BufferSubgraph).compareTo((o2 as BufferSubgraph)));
  var list = subgraphList.reversed.toList();
  return list;
}