Fügt dem Graphen einen Knoten hinzu

@return Vertice gibt die eingefügte Vertice zurück
422990
public function addV(Vertice $u) {
    if (!array_key_exists($u->label,$this->V))
      $this->V[$u->label] =& $u;
    
    return $this->V[$u->label];
  }
449820
public function getRootParagraph()
    {
        if ( $this->proxyBase->rootId && (
                null === $this->rootParagraph ||
                $this->rootParagraph->id != $this->proxyBase->rootId
            ) )
        {
            $this->rootParagraph = $this->getMapper()
                                        ->find( $this->proxyBase->rootId );
        }

        return $this->rootParagraph;
    }
862673
function() {
        if (this.degrees === 0) {
            return this.clone();
        }
        var topLeft = this.getTopLeft();
        var topRight = this.getTopRight();
        var bottomLeft = this.getBottomLeft();
        var bottomRight = this.getBottomRight();
        var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
        var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
        var minY = Math.min(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
        var maxY = Math.max(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
        return new $.Rect(
            minX,
            minY,
            maxX - minX,
            maxY - minY);
    }
1027656
public Graph toGraph()
    {
        Graph graph = new Graph(getVertexesLineFirst());

        for (int row = 0; row < vertexes.length - 1; ++row)
        {
            List<Vertex> vertexListFrom = vertexes[row];
            for (Vertex from : vertexListFrom)
            {
                assert from.realWord.length() > 0 : "空节点会导致死循环！";
                int toIndex = row + from.realWord.length();
                for (Vertex to : vertexes[toIndex])
                {
                    graph.connect(from.index, to.index, MathUtility.calculateWeight(from, to));
                }
            }
        }
        return graph;
    }
860875
public GridNode goDownstreamSP() {
        Direction[] orderedDirs = Direction.getOrderedDirs();
        double maxSlope = Double.NEGATIVE_INFINITY;
        GridNode nextNode = null;
        for( Direction direction : orderedDirs ) {
            int newCol = col + direction.col;
            int newRow = row + direction.row;
            if (isInRaster(newCol, newRow)) {
                GridNode node = new GridNode(gridIter, cols, rows, xRes, yRes, newCol, newRow);
                if (node.isValid()) {
                    double slopeTo = getSlopeTo(node);
                    if (slopeTo > 0 && slopeTo > maxSlope) {
                        nextNode = node;
                        maxSlope = slopeTo;
                    }
                }
            }
        }
        if (nextNode == null && !isPit) {
            isOutlet = true;
        }
        return nextNode;
    }
8741
public String graph() {// throws Exception {
        StringBuffer text = new StringBuffer();

        text.append("digraph CobwebTree {\n");
        m_cobwebTree.graphTree(text);
        text.append("}\n");
        return text.toString();
    }
270198
@Override
    public Iterable<GraphEdge<V, E>> edges() {
        return F.map(vedges(), new Function<Map.Entry<V, GraphEdge<V, E>>, GraphEdge<V, E>>() {
            @Override
            public GraphEdge<V, E> apply(Map.Entry<V, GraphEdge<V, E>> entry) {
                return entry.getValue();
            }
        });
    }
364444
public DashedVerticalLine dashedVerticalLineInstance() {
           LineObject lineObject = new LineObject();
           DashedVerticalLine dashedVerticalLine = lineObject.dashedVerticalLineInstance();
		objectsInstance().add(lineObject);
		return dashedVerticalLine;
	}
528478
public function getCallGraph()
    {
        $node = $root = new Node(array());
        foreach ($this->getQueries() as $query) {
            foreach (array_reverse($query['trace']) as $trace) {
                $node = $node->push($trace);
            }
            $node->addValue($query);
            $node = $root;
        }

        return $root;
    }
875697
public function getDegree()
    {
        $max = null;
        foreach ($this->graph->getVertices() as $vertex) {
            $num = count($this->getVerticesChildren($vertex));
            if ($max === null || $num > $max) {
                $max = $num;
            }
        }
        if ($max === null) {
            throw new UnderflowException('No vertices found');
        }
        return $max;
    }
420243
public function getEdgesIn()
    {
        $that = $this;

        return $this->getEdges()->getEdgesMatch(function (Edge $edge) use ($that) {
            return $edge->hasVertexTarget($that);
        });
    }
658879
public Graph<K, VV, EV> reverse() throws UnsupportedOperationException {
		DataSet<Edge<K, EV>> reversedEdges = edges.map(new ReverseEdgesMap<>()).name("Reverse edges");
		return new Graph<>(vertices, reversedEdges, this.context);
	}
1282950
public static SimpleGraph<String, DefaultEdge> getSimpleGraphFromUser() {
        Scanner sc = new Scanner(System.in);
        SimpleGraph<String, DefaultEdge> graph = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);

        // input number of vertices
        int verticeAmount;
        do {
            System.out.print("Enter the number of vertices (more than one): ");
            verticeAmount = sc.nextInt();
        } while (verticeAmount <= 1);

        // input vertices
        for (int i = 1; i <= verticeAmount; i++) {
            System.out.print("Enter vertex name " + i + ": ");
            String input = sc.next();
            if (graph.vertexSet().contains(input)) {
                System.err.println("vertex with that name already exists");
                i--;
            } else {
                graph.addVertex(input);
            }
        }

        // input edges
        System.out.println("\nEnter edge (name => name)");
        String userWantsToContinue;
        do {
            String e1, e2;
            
            do {
                System.out.print("Edge from: ");
                e1 = sc.next();
            } while (!graph.vertexSet().contains(e1));
            do {
                System.out.print("Edge to: ");
                e2 = sc.next();
            } while (!graph.vertexSet().contains(e2));

            graph.addEdge(e1, e2);

            // add another edge?
            System.out.print("Add more edges? (y/n): ");
            userWantsToContinue = sc.next();
        }while (userWantsToContinue.equals("y") || userWantsToContinue.equals("yes") || userWantsToContinue.equals("1"));

        return graph;
    }
510413
public Graph<Node> moduleGraph() {
        Graph.Builder<Node> builder = new Graph.Builder<>();

        archives().stream()
            .forEach(m -> {
                Node u = new Node(m.getName(), Info.REQUIRES);
                builder.addNode(u);
                analyzer.requires(m)
                    .map(req -> new Node(req.getName(), Info.REQUIRES))
                    .forEach(v -> builder.addEdge(u, v));
            });
        return builder.build();
    }
172400
static boolean getConsistent(DirectedGraph g) {
        Object[] vertexOrdering = new Object[g.size()];
        int voa = 0;
        for (Iterator<?> itr = g.iterator(); itr.hasNext(); voa++) {
            vertexOrdering[voa] = itr.next();
        }
        int vol = vertexOrdering.length;
        Weight[][] updatedEdges = new Weight[vol][vol];
        for (int k = vol - 1; k > 1; k--) {
            Object vk = vertexOrdering[k];
            for (int i = 0; i < k; i++) {
                Object vi = vertexOrdering[i];
                Weight wik = getWeight(i, k, vi, vk, g, updatedEdges);
                if (wik != null) {
                    /*
                     * wki may be different from wik, so we can't just get the
                     * inverse of wik.
                     */
                    Weight wki = getWeight(k, i, vk, vi, g, updatedEdges);
                    // i > j because we evaluate the vertices in order.
                    for (int j = i + 1; j < k; j++) {
                        Object vj = vertexOrdering[j];
                        Weight wjk = getWeight(j, k, vj, vk, g, updatedEdges);
                        if (wjk != null) {
                            Weight wkj = getWeight(k, j, vk, vj, g,
                                    updatedEdges);
                            Weight wikj = wik.add(wkj);
                            Weight wjki = wjk.add(wki);
                            Weight wij = getWeight(i, j, vi, vj, g,
                                    updatedEdges);
                            Weight wji = getWeight(j, i, vj, vi, g,
                                    updatedEdges);
                            Weight iwjki = wjki.invertSign();
                            Weight iwji = null;
                            if (wji != null) {
                                iwji = wji.invertSign();
                            }
                            if (wij != null) {
                                Weight intersectionMin = Weight.max(iwji, iwjki);
                                Weight intersectionMax = Weight.min(wij, wikj);
                                if (intersectionMin.compareTo(intersectionMax) > 0) {
                                    return false;
                                }
                                updatedEdges[i][j] = intersectionMax;
                                updatedEdges[j][i] = intersectionMin.invertSign();
                            } else {
                                updatedEdges[i][j] = wikj;
                                updatedEdges[j][i] = wjki;
                            }
                        }
                    }
                }
            }
        }

        return true;
    }
252137
public Multigraph<T,E> next() {
        if (!hasNext())
            throw new NoSuchElementException();
        Multigraph<T,E> cur = next.poll();
        if (next.isEmpty())
            advance();
        return cur;
    }
117353
public Graph<K, VV, EV> filterOnVertices(FilterFunction<Vertex<K, VV>> vertexFilter) {

		DataSet<Vertex<K, VV>> filteredVertices = this.vertices.filter(vertexFilter);

		DataSet<Edge<K, EV>> remainingEdges = this.edges.join(filteredVertices)
				.where(0).equalTo(0).with(new ProjectEdge<>())
				.join(filteredVertices).where(1).equalTo(0)
				.with(new ProjectEdge<>()).name("Filter on vertices");

		return new Graph<>(filteredVertices, remainingEdges, this.context);
	}