public void traverse(Object vertex,boolean directed,mxICellVisitor visitor,Object edge,Set<Object> visited){
  if (vertex != null && visitor != null) {
    if (visited == null) {
      visited=new HashSet<Object>();
    }
    if (!visited.contains(vertex)) {
      visited.add(vertex);
      if (visitor.visit(vertex,edge)) {
        int edgeCount=model.getEdgeCount(vertex);
        if (edgeCount > 0) {
          for (int i=0; i < edgeCount; i++) {
            Object e=model.getEdgeAt(vertex,i);
            boolean isSource=model.getTerminal(e,true) == vertex;
            if (!directed || isSource) {
              Object next=model.getTerminal(e,!isSource);
              traverse(next,directed,visitor,e,visited);
            }
          }
        }
      }
    }
  }
}

public void traverse ( Object vertex , boolean directed , mxICellVisitor visitor , Object edge , Set < Object > visited ) { if ( vertex != null && visitor != null ) { if ( visited == null ) { visited = new HashSet < Object > ( ) ; } if ( ! visited . contains ( vertex ) ) { visited . add ( vertex ) ; if ( visitor . visit ( vertex , edge ) ) { int edgeCount = model . getEdgeCount ( vertex ) ; if ( edgeCount > 0 ) { for ( int i = 0 ; i < edgeCount ; i ++ ) { Object e = model . getEdgeAt ( vertex , i ) ; boolean isSource = model . getTerminal ( e , true ) == vertex ; if ( ! directed || isSource ) { Object next = model . getTerminal ( e , ! isSource ) ; traverse ( next , directed , visitor , e , visited ) ; } } } } } } }
traverses the ( directed ) graph invoking the given function for each visited vertex and edge . the function is invoked with the current vertex and the incoming edge as a parameter . this implementation makes sure each vertex is only visited once . the function may return false if the traversal should stop at the given vertex .
