private UndirectedGraph dupGraph (UndirectedGraph original) { UndirectedGraph copy = new SimpleGraph (); GraphHelper.addGraph (copy, original); return copy; }
ListenableUndirectedGraph g = new ListenableUndirectedGraph (new SimpleGraph ()); g.addVertex (c); g.addGraphListener (inspector); g.addEdge(pair[0], pair[1]); edgesAdded++;
/** * Creates a molecule graph for use with jgrapht. * Bond orders are not respected. * * @param molecule the specified molecule * @return a graph representing the molecule */ static public SimpleGraph getMoleculeGraph(IAtomContainer molecule) { SimpleGraph graph = new SimpleGraph(); for (int i = 0; i < molecule.getAtomCount(); i++) { IAtom atom = molecule.getAtom(i); graph.addVertex(atom); } for (int i = 0; i < molecule.getBondCount(); i++) { IBond bond = molecule.getBond(i); /* * int order = (int) bond.getOrder(); for (int j=0; j<order; j++) { * graph.addEdge(bond.getAtoms()[0], bond.getAtoms()[1]); } */ graph.addEdge(bond.getBegin(), bond.getEnd()); } return graph; }
Graph subgraph = new Subgraph(graph, connectedSet, null); SimpleGraph h = new SimpleGraph(); h.addAllVertices(treeEdges); Edge l = (Edge) adjacentEdges.next(); if (!treeEdges.contains(l)) { h.addVertex(l); Object u = l.oppositeVertex(v); Edge f = subgraph.getEdge(u, pu); h.addEdge(f, l);
@Override public List edgesOf(Object auxVertex) { Object vertex = auxVertexMap.get(auxVertex); for (Iterator edgeIterator = g.edgesOf(vertex).iterator(); edgeIterator.hasNext();) { Edge edge = (Edge) edgeIterator.next(); int j = getEdgeIndex(edge); Object vertex1 = edge.getSource(); Object vertex2 = edge.getTarget(); if (u[j]) { Object vertex1u = auxVertex0(vertex1); Object vertex2u = auxVertex1(vertex2); Edge auxEdge = addEdge(vertex1u, vertex2u); auxEdgeMap.put(auxEdge, edge); vertex1u = auxVertex1(vertex1); vertex2u = auxVertex0(vertex2); auxEdge = addEdge(vertex1u, vertex2u); auxEdgeMap.put(auxEdge, edge); } else { Object vertex1u = auxVertex0(vertex1); Object vertex2u = auxVertex0(vertex2); Edge auxEdge = addEdge(vertex1u, vertex2u); auxEdgeMap.put(auxEdge, edge); vertex1u = auxVertex1(vertex1); vertex2u = auxVertex1(vertex2); auxEdge = addEdge(vertex1u, vertex2u); auxEdgeMap.put(auxEdge, edge); } } return super.edgesOf(auxVertex); }
UndirectedGraph simpleGraph = new UndirectedSubgraph(g, null, null); vertices.add(edge.getTarget()); UndirectedGraph subgraph = new UndirectedSubgraph(simpleGraph, vertices, edges);
shortestPathGraph = new DefaultDirectedGraph(); shortestPathGraph.addVertex(targetVertex);
ListenableUndirectedGraph g = new ListenableUndirectedGraph (new SimpleGraph ()); g.addVertex (c); g.addGraphListener (inspector); g.addEdge(pair[0], pair[1]); edgesAdded++;
private UndirectedGraph dupGraph (UndirectedGraph original) { UndirectedGraph copy = new SimpleGraph (); GraphHelper.addGraph (copy, original); return copy; }
return super.edgesOf(auxVertex);
ListenableUndirectedGraph g = new ListenableUndirectedGraph (new SimpleGraph ()); g.addVertex (c); g.addGraphListener (inspector); g.addEdge(pair[0], pair[1]); edgesAdded++;
private UndirectedGraph dupGraph (UndirectedGraph original) { UndirectedGraph copy = new SimpleGraph (); GraphHelper.addGraph (copy, original); return copy; }
/** * Converts a FactorGraph into a plain graph where each Variable is a vertex, * and two Variables are connected by an edge if they are arguments to the same factor. * (Essentially converts an fg into an MRF structure, minus the factors.) * @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; }
/** * Converts a FactorGraph into a plain graph where each Variable is a vertex, * and two Variables are connected by an edge if they are arguments to the same factor. * (Essentially converts an fg into an MRF structure, minus the factors.) * @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; }
/** * Converts a FactorGraph into a plain graph where each Variable is a vertex, * and two Variables are connected by an edge if they are arguments to the same factor. * (Essentially converts an fg into an MRF structure, minus the factors.) * @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; }
UndirectedGraph g = new SimpleGraph (); for (Iterator it = fullGraph.variablesIterator (); it.hasNext ();) { Variable var = (Variable) it.next ();
UndirectedGraph g = new SimpleGraph (); for (Iterator it = fullGraph.variablesIterator (); it.hasNext ();) { Variable var = (Variable) it.next ();
UndirectedGraph g = new SimpleGraph (); for (Iterator it = fullGraph.variablesIterator (); it.hasNext ();) { Variable var = (Variable) it.next ();
UndirectedGraph h = new SimpleGraph(); h.addAllVertices(cycles);