Пример #1
0
  /**
   * Returns a set of all vertices that are in the maximally connected component together with the
   * specified vertex. For more on maximally connected component, see <a
   * href="http://www.nist.gov/dads/HTML/maximallyConnectedComponent.html">
   * http://www.nist.gov/dads/HTML/maximallyConnectedComponent.html</a>.
   *
   * @param vertex the vertex for which the connected set to be returned.
   * @return a set of all vertices that are in the maximally connected component together with the
   *     specified vertex.
   */
  public Set connectedSetOf(Object vertex) {
    Set connectedSet = (Set) m_vertexToConnectedSet.get(vertex);

    if (connectedSet == null) {
      connectedSet = new HashSet();

      BreadthFirstIterator i = new BreadthFirstIterator(m_graph, vertex);

      while (i.hasNext()) {
        connectedSet.add(i.next());
      }

      m_vertexToConnectedSet.put(vertex, connectedSet);
    }

    return connectedSet;
  }
Пример #2
0
  private List lazyFindConnectedSets() {
    if (m_connectedSets == null) {
      m_connectedSets = new ArrayList();

      Set vertexSet = m_graph.vertexSet();

      if (vertexSet.size() > 0) {
        BreadthFirstIterator i = new BreadthFirstIterator(m_graph, null);
        i.addTraversalListener(new MyTraversalListener());

        while (i.hasNext()) {
          i.next();
        }
      }
    }

    return m_connectedSets;
  }
Пример #3
0
 @Override
 protected void encounterVertex(Object vertex, Edge edge) {
   super.encounterVertex(vertex, edge);
   putSeenData(vertex, edge);
 }