/** * Returns a graph in which each pair of vertices is connected by * an undirected edge with the probability specified by the constructor. */ public Graph<V,E> get() { UndirectedGraph<V,E> g = graphFactory.get(); for(int i=0; i<mNumVertices; i++) { g.addVertex(vertexFactory.get()); } List<V> list = new ArrayList<V>(g.getVertices()); for (int i = 0; i < mNumVertices-1; i++) { V v_i = list.get(i); for (int j = i+1; j < mNumVertices; j++) { V v_j = list.get(j); if (mRandom.nextDouble() < mEdgeConnectionProbability) { g.addEdge(edgeFactory.get(), v_i, v_j); } } } return g; }
high.put(v, v_dfs_num); for (V w : g.getNeighbors(v)) E vw = g.findEdge(v,w); if (w_dfs_num == 0) // w hasn't yet been visited bicomponent.addAll(g.getIncidentVertices(e));
if (theGraph.getVertices().isEmpty()) return bicomponents; for (V v : theGraph.getVertices()) for (V v : theGraph.getVertices()) stack = new Stack<E>(); parents = new HashMap<V,V>(); converse_depth = theGraph.getVertexCount(); if (theGraph.getVertexCount() - converse_depth == 1)
String i1 = "" + i; String i2 = "" + j; g.addEdge(Math.pow(i+2,j), i1, i2); String i1 = "" + i; String i2 = "" + j; g.addEdge(Math.pow(i+2,j), i1, i2); index.addAll(g.getVertices()); g.addEdge(new Integer(i), index.get(i), index.get(i+1));
UndirectedGraph<String, UnorderedPair<String>> undirectedWNPPGraph = new UndirectedSparseGraph<String, UnorderedPair<String>>(); for (String vertex : undirectedWNGraph.getVertices()) { undirectedWNPPGraph.addVertex(vertex); undirectedWNPPGraph.addEdge(edge, undirectedWNGraph.getEndpoints(edge)); UnorderedPair<String> edge = new UnorderedPair<String>(source, target); if (undirectedWNPPGraph.containsEdge(edge)) { duplicateRelations++; continue; undirectedWNPPGraph.addEdge(edge, source, target); + " edges"); logger.info("New graph contains " + undirectedWNPPGraph.getVertexCount() + " vertices and " + undirectedWNPPGraph.getEdgeCount() + " edges"); if (undirectedWNPPGraph.getVertexCount() > undirectedWNGraph .getVertexCount()) { logger.error("WordNet++ semantic relations reference nonexistent WordNet synsets -- probable WordNet version mismatch");
if (edge.getWeight() == weight) { Pair<LabelVertex> endpts = affinityGraph.getEndpoints(edge); affinityGraph.removeEdge(edge); for (LabelVertex end : endpts) { if (affinityGraph.degree(end) == 0) { affinityGraph.removeVertex(end); identMap.remove(end.getIdentity());
/** * Adds a vertex for the given identity to the graph, or retrieve the * existing one. * @param id the identity * @return the graph vertex representing the identity */ private LabelVertex addOrGetVertex(Identity id) { assert Thread.holdsLock(affinityGraph); LabelVertex v = getVertex(id); if (v == null) { v = new LabelVertex(id); affinityGraph.addVertex(v); identMap.put(id, v); } return v; }
Collection<LabelVertex> graphVertices = graph.getVertices(); if (graphVertices == null) { vertices = new ArrayList<LabelVertex>();
@Override public Set<String> getSenseNeighbours(String senseId) throws SenseInventoryException, UnsupportedOperationException { return new HashSet<String>(undirectedWNPPGraph.getNeighbors(senseId)); }
Synset s = (Synset) i.next(); String s_name = synsetToString.transform(s); undirectedWNGraph.addVertex(s_name); synsetCount++; for (Pointer p : s.getPointers()) { UnorderedPair<String> e = pointerToUnorderedPair .transform(p); if (!undirectedWNGraph.containsEdge(e)) { undirectedWNGraph.addEdge(e, s_name, synsetToString .transform(p.getTargetSynset())); throw new SenseInventoryException(e); logger.info("# vertices = " + undirectedWNGraph.getVertexCount() + "; # synsets = " + synsetCount + "; # edges = " + undirectedWNGraph.getEdgeCount() + "; # pointers = " + pointerCount);
if (edge.getWeight() == weight) { Pair<LabelVertex> endpts = affinityGraph.getEndpoints(edge); affinityGraph.removeEdge(edge); for (LabelVertex end : endpts) { if (affinityGraph.degree(end) == 0) { affinityGraph.removeVertex(end); identMap.remove(end.getIdentity());
String i1 = "" + i; String i2 = "" + j; g.addEdge(Math.pow(i + 2, j), i1, i2); g.addEdge(Math.pow(i + 2, j), i1, i2); index.addAll(g.getVertices()); g.addEdge(Integer.valueOf(i), index.get(i), index.get(i + 1));
/** * Adds a vertex for the given identity to the graph, or retrieve the * existing one. * @param id the identity * @return the graph vertex representing the identity */ private LabelVertex addOrGetVertex(Identity id) { assert Thread.holdsLock(affinityGraph); LabelVertex v = getVertex(id); if (v == null) { v = new LabelVertex(id); affinityGraph.addVertex(v); identMap.put(id, v); } return v; }