Examples of SimpleGraph


Examples of com.evelopers.unimod.glayout.graph.SimpleGraph

     *
     *
     * @param args
     */
    public static void main(String[] args) {
        SimpleGraph sg  = GraphGenerator.generateTriangles();
        SimpleGraph sg1 = GraphGenerator.generateOneV();
        ((SimpleVertex) sg.getVertices()
                          .get(2)).setProperty(Constant.LAYER_KEY, sg1);

        SimpleVertex test1 = (SimpleVertex) sg.getVertices()
                                              .get(3);
        SimpleVertex test2 = (SimpleVertex) sg1.getVertices()
                                               .get(0);
        SimpleEdge e = new SimpleEdge(test2, test1);
        sg.addEdge(e);

        long time = System.currentTimeMillis();
View Full Code Here

Examples of com.evelopers.unimod.glayout.graph.SimpleGraph

            sg.removePropertyAsc(ESUBGRAPH_KEY);

            return;
        }

        SimpleGraph blk = provideBLK(sg, cutpoints);

        sg.removePropertyAsc(ESUBGRAPH_KEY);

        // getting list to connect vertices
        ListIterator liv = blk.getVertices()
                              .listIterator();

        // toconnect will be from sg vertices
        List toconnect = new ArrayList();
View Full Code Here

Examples of com.evelopers.unimod.glayout.graph.SimpleGraph

     * @param sg
     * @param cutpoints
     * @return
     */
    private static SimpleGraph provideBLK(SimpleGraph sg, List cutpoints) {
        SimpleGraph blk = new SimpleGraph();

        // adding cutpoints
        ListIterator licp = cutpoints.listIterator();

        while (licp.hasNext()) {
            SimpleVertex element = (SimpleVertex) licp.next();
            SimpleVertex toadd   = new SimpleVertex();
            blk.addVertex(toadd);
            toadd.setProperty(CORRESP_KEY, element);
            element.setProperty(CORRESP_KEY, toadd);
        }

        // searching for biconn subgraph count
        int esub_count   = 0;
        ListIterator lie = sg.getEdges()
                             .listIterator();

        while (lie.hasNext()) {
            SimpleEdge element = (SimpleEdge) lie.next();
            int esub_n         = element.getIntProperty(ESUBGRAPH_KEY);

            if (esub_n > esub_count) {
                esub_count = esub_n;
            }
        }

        // creating vertices
        SimpleVertex[] white = new SimpleVertex[esub_count];

        for (int i = 0; i < white.length; i++) {
            white[i] = new SimpleVertex();
            blk.addVertex(white[i]);
        }

        // setting vertex corresp
        lie = sg.getEdges()
                .listIterator();

        while (lie.hasNext()) {
            SimpleEdge element  = (SimpleEdge) lie.next();
            SimpleVertex svcomp = white[element.getIntProperty(ESUBGRAPH_KEY) - 1];
            SimpleVertex v1     = element.getSource();
            SimpleVertex v2     = element.getTarget();

            //setting corresp vertex not from cutpoints
            if ((svcomp.getVertexProperty(CORRESP_KEY) == null)
                    || (!cutpoints.contains(v1))) {
                svcomp.setProperty(CORRESP_KEY, v1);
            }

            if ((svcomp.getVertexProperty(CORRESP_KEY) == null)
                    || (!cutpoints.contains(v2))) {
                svcomp.setProperty(CORRESP_KEY, v2);
            }
        }

        // adding edges
        licp = cutpoints.listIterator();

        while (licp.hasNext()) {
            SimpleVertex element = (SimpleVertex) licp.next();
            SimpleVertex svcutp  = element.getVertexProperty(CORRESP_KEY);
            ListIterator liedges = element.getEdgesRelative(sg)
                                          .listIterator();

            List v2c = new ArrayList();

            // but no duplicate edges
            while (liedges.hasNext()) {
                SimpleEdge edge     = (SimpleEdge) liedges.next();
                SimpleVertex svcomp = white[edge.getIntProperty(ESUBGRAPH_KEY) - 1];

                if (!v2c.contains(svcomp)) {
                    v2c.add(svcomp);
                }
            }

            ListIterator liv2c = v2c.listIterator();

            while (liv2c.hasNext()) {
                SimpleVertex vertex = (SimpleVertex) liv2c.next();

                SimpleEdge toadd = new SimpleEdge(svcutp, vertex);
                blk.addEdge(toadd);
            }
        }

        sg.removePropertyAsc(CORRESP_KEY);

View Full Code Here

Examples of com.intel.hadoop.graphbuilder.graph.simplegraph.SimpleGraph

*/
public class SimpleGraphTest {

  @Test
  public void testEmptyGraph() {
    SimpleGraph mygraph = new SimpleGraph();
    assertEquals(mygraph.numEdges(), 0);
  }
View Full Code Here

Examples of com.intel.hadoop.graphbuilder.graph.simplegraph.SimpleGraph

    assertEquals(mygraph.numEdges(), 0);
  }

  @Test
  public void testSmallGraph() {
    SimpleGraph mygraph = new SimpleGraph();
    List<Integer> sources = Arrays.asList(1, 2, 3, 4, 5);
    List<Integer> targets = Arrays.asList(5, 4, 3, 2, 1);
    List<Character> edata = Arrays.asList('a', 'b', 'c', 'd', 'e');

    assertEquals(mygraph.numEdges(), 0);
    for (int i = 0; i < sources.size(); i++) {
      mygraph.addEdge(sources.get(i), targets.get(i), edata.get(i));
    }
    assertEquals(mygraph.numEdges(), sources.size());
  }
View Full Code Here

Examples of com.intel.hadoop.graphbuilder.graph.simplegraph.SimpleGraph

    assertEquals(mygraph.numEdges(), sources.size());
  }

  @Test
  public void testGraphFormatter() {
    SimpleGraph mygraph = new SimpleGraph();
    List<Integer> sources = Arrays.asList(1, 2, 3, 4, 5);
    List<Integer> targets = Arrays.asList(5, 4, 3, 2, 1);
    List<String> edata = Arrays.asList("a", "b", "c", "d", "e");

    assertEquals(mygraph.numEdges(), 0);
    mygraph.addEdges(sources, targets, edata);
    assertEquals(mygraph.numEdges(), sources.size());

    SimpleJsonFormatter formatter = new SimpleJsonFormatter();
    String s = formatter.structWriter(mygraph).toString();
    String expected = "{\"source\":1,\"targets\":[5]}\n"
        + "{\"source\":2,\"targets\":[4]}\n"
View Full Code Here

Examples of org._3pq.jgrapht.graph.SimpleGraph

   * @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

Examples of org._3pq.jgrapht.graph.SimpleGraph

        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

Examples of org._3pq.jgrapht.graph.SimpleGraph

    // ...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

Examples of org._3pq.jgrapht.graph.SimpleGraph

    return jtCurrent;
  }

  private UndirectedGraph dupGraph (UndirectedGraph original)
  {
    UndirectedGraph copy = new SimpleGraph ();
    GraphHelper.addGraph (copy, original);
    return copy;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.