Package org._3pq.jgrapht.ext

Examples of org._3pq.jgrapht.ext.JGraphModelAdapter


    // ...and add the edges to jt that come to the top of the queue
    //  and don't cause a cycle.
    // xxx OK, this sucks.  openjgraph doesn't allow adding
    //  disconnected edges to a tree, so what we'll do is create a
    //  Graph frist, then convert it to a Tree.
    ListenableUndirectedGraph g = new ListenableUndirectedGraph (new SimpleGraph ());

    // first add every clique to the graph
    for (Iterator it = cliques.iterator(); it.hasNext();) {
      VarSet c = (VarSet) it.next();
      g.addVertex (c);
    }

    ConnectivityInspector inspector = new ConnectivityInspector (g);
    g.addGraphListener (inspector);
   
    // then add n - 1 edges
    int numCliques = cliques.size();
    int edgesAdded = 0;
    while (edgesAdded < numCliques - 1) {
      VarSet[] pair = (VarSet[]) pq.first();
      pq.remove(pair);

      if (!inspector.pathExists(pair[0], pair[1])) {
          g.addEdge(pair[0], pair[1]);
          edgesAdded++;
      }
    }

    JunctionTree jt = graphToJt(g);
View Full Code Here


   * @param fg
   * @return a Graph
   */
  public static UndirectedGraph mdlToGraph (FactorGraph fg)
  {
    UndirectedGraph g = new SimpleGraph ();

    for (Iterator it = fg.variablesIterator (); it.hasNext ();) {
      Variable var = (Variable) it.next ();
      g.addVertex (var);
    }

    for (Iterator it = fg.factorsIterator (); it.hasNext ();) {
      Factor factor = (Factor) it.next ();
      VarSet varSet = factor.varSet ();
      int nv = varSet.size ();
      for (int i = 0; i < nv; i++) {
        for (int j = i + 1; j < nv; j++) {
          g.addEdge (varSet.get (i), varSet.get (j));
        }
      }
    }

    return g;
View Full Code Here

        for (Iterator it = goodEdges.iterator (); it.hasNext ();) {
          Factor factor = (Factor) it.next ();
          touchFactor (factor);
        }

        UndirectedGraph g = new SimpleGraph ();
        for (Iterator it = fullGraph.variablesIterator (); it.hasNext ();) {
          Variable var = (Variable) it.next ();
          g.addVertex (var);
        }

        for (Iterator it = goodEdges.iterator (); it.hasNext ();) {
          Factor factor = (Factor) it.next ();
          g.addVertex (factor);
          for (Iterator vit = factor.varSet ().iterator (); vit.hasNext ();) {
            Variable var = (Variable) vit.next ();
            g.addEdge (factor, var);
          }
        }

        Tree tree = graphToTree (g);
        if (reportSpanningTrees) {
View Full Code Here

    // ...and add the edges to jt that come to the top of the queue
    //  and don't cause a cycle.
    // xxx OK, this sucks.  openjgraph doesn't allow adding
    //  disconnected edges to a tree, so what we'll do is create a
    //  Graph frist, then convert it to a Tree.
    ListenableUndirectedGraph g = new ListenableUndirectedGraph (new SimpleGraph ());

    // first add every clique to the graph
    for (Iterator it = cliques.iterator(); it.hasNext();) {
      VarSet c = (VarSet) it.next();
      g.addVertex (c);
View Full Code Here

    return jtCurrent;
  }

  private UndirectedGraph dupGraph (UndirectedGraph original)
  {
    UndirectedGraph copy = new SimpleGraph ();
    GraphHelper.addGraph (copy, original);
    return copy;
  }
View Full Code Here

    }
    Tree tree = new cc.mallet.grmm.types.Tree ();
    Object root = g.vertexSet ().iterator ().next ();
    tree.add (root);

    for (Iterator it1 = new BreadthFirstIterator (g, root); it1.hasNext();) {
      Object v1 = it1.next ();
      for (Iterator it2 = g.edgesOf (v1).iterator (); it2.hasNext ();) {
        Edge edge = (Edge) it2.next ();
        Object v2 = edge.oppositeVertex (v1);
          if (tree.getParent (v1) != v2) {
            tree.addNode (v1, v2);
View Full Code Here

  {
    JunctionTree jt = new JunctionTree (g.vertexSet ().size ());
    Object root = g.vertexSet ().iterator ().next ();
    jt.add (root);

    for (Iterator it1 = new BreadthFirstIterator (g, root); it1.hasNext ();) {
      Object v1 = it1.next ();
      for (Iterator it2 = GraphHelper.neighborListOf (g, v1).iterator (); it2.hasNext ();) {
        Object v2 = it2.next ();
        if (jt.getParent (v1) != v2) {
          jt.addNode (v1, v2);
        }
View Full Code Here

TOP

Related Classes of org._3pq.jgrapht.ext.JGraphModelAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.