Java Code Examples for org.jgrapht.traverse.DepthFirstIterator#hasNext()

The following examples show how to use org.jgrapht.traverse.DepthFirstIterator#hasNext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MasterGraphChangeHandler.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
private void loadAddons()
{
   DepthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new DepthFirstIterator<AddonVertex, AddonDependencyEdge>(
            graph.getGraph());

   iterator.addTraversalListener(new TraversalListenerAdapter<AddonVertex, AddonDependencyEdge>()
   {
      @Override
      public void vertexFinished(VertexTraversalEvent<AddonVertex> event)
      {
         Addon addon = event.getVertex().getAddon();
         if (!addon.getStatus().isLoaded())
            lifecycleManager.loadAddon(addon);
      };
   });

   while (iterator.hasNext())
      iterator.next();
}
 
Example 2
Source File: MasterGraphChangeHandler.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
private void startupIncremental()
{
   DepthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new DepthFirstIterator<AddonVertex, AddonDependencyEdge>(
            graph.getGraph());

   iterator.addTraversalListener(new TraversalListenerAdapter<AddonVertex, AddonDependencyEdge>()
   {
      @Override
      public void vertexFinished(VertexTraversalEvent<AddonVertex> event)
      {
         Addon addon = event.getVertex().getAddon();
         if (addon.getStatus().isLoaded())
            lifecycleManager.startAddon(addon);
      };
   });

   while (iterator.hasNext())
      iterator.next();
}
 
Example 3
Source File: MasterGraphChangeHandler.java    From furnace with Eclipse Public License 1.0 6 votes vote down vote up
private void clearDirtyStatus()
{
   DepthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new DepthFirstIterator<AddonVertex, AddonDependencyEdge>(
            graph.getGraph());

   iterator.addTraversalListener(new TraversalListenerAdapter<AddonVertex, AddonDependencyEdge>()
   {
      @Override
      public void vertexFinished(VertexTraversalEvent<AddonVertex> event)
      {
         event.getVertex().setDirty(false);
      };
   });

   while (iterator.hasNext())
      iterator.next();
}
 
Example 4
Source File: AddonGraph.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String toString()
{
   DepthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new DepthFirstIterator<AddonVertex, AddonDependencyEdge>(
            getGraph());

   final StringBuilder builder = new StringBuilder();
   iterator.addTraversalListener(new PrintGraphTraversalListener(getGraph(), builder));

   while (iterator.hasNext())
      iterator.next();

   return builder.toString();
}
 
Example 5
Source File: MasterGraph.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
public void merge(final OptimizedAddonGraph other)
{
   if (other.getGraph().vertexSet().isEmpty())
      return;

   if (graph.vertexSet().isEmpty())
   {
      for (AddonVertex vertex : other.getGraph().vertexSet())
      {
         mergeVertex(other, vertex);
      }
   }
   else
   {
      DepthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new DepthFirstIterator<AddonVertex, AddonDependencyEdge>(
               other.getGraph());

      iterator.addTraversalListener(new TraversalListenerAdapter<AddonVertex, AddonDependencyEdge>()
      {
         @Override
         public void vertexTraversed(VertexTraversalEvent<AddonVertex> event)
         {
            mergeVertex(other, event.getVertex());
         };
      });

      while (iterator.hasNext())
         iterator.next();
   }
}
 
Example 6
Source File: MasterGraph.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String toString()
{
   DepthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new DepthFirstIterator<AddonVertex, AddonDependencyEdge>(
            getGraph());

   final StringBuilder builder = new StringBuilder();
   iterator.addTraversalListener(new PrintGraphTraversalListener(getGraph(), builder));

   while (iterator.hasNext())
      iterator.next();

   return builder.toString();
}
 
Example 7
Source File: MasterGraphChangeHandler.java    From furnace with Eclipse Public License 1.0 4 votes vote down vote up
private void markDirty()
{
   DepthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new DepthFirstIterator<AddonVertex, AddonDependencyEdge>(
            graph.getGraph());

   iterator.addTraversalListener(new TraversalListenerAdapter<AddonVertex, AddonDependencyEdge>()
   {
      @Override
      public void vertexFinished(VertexTraversalEvent<AddonVertex> event)
      {
         // If this vertex is missing or any dependency was missing (is dirty), then this is dirty also
         AddonVertex vertex = event.getVertex();
         Addon addon = vertex.getAddon();
         if (!addon.getStatus().isLoaded() || addon.getStatus().isFailed())
         {
            vertex.setDirty(true);
         }

         for (AddonDependencyEdge edge : graph.getGraph().outgoingEdgesOf(vertex))
         {
            AddonVertex target = graph.getGraph().getEdgeTarget(edge);
            if (target.isDirty())
               vertex.setDirty(true);
         }

         if (lastMasterGraph != null)
         {
            boolean equivalent = false;
            Set<AddonVertex> lastVertices = lastMasterGraph.getVertices(vertex.getName(), vertex.getVersion());
            for (AddonVertex lastVertex : lastVertices)
            {
               if (graph.isSubtreeEquivalent(vertex, lastMasterGraph.getGraph(), lastVertex))
               {
                  equivalent = true;
                  break;
               }
            }

            if (!equivalent)
               vertex.setDirty(true);
         }
      };
   });

   while (iterator.hasNext())
      iterator.next();
}