This operation adds all inverse-direction edges to the graph.

@return the undirected graph.
511087
public Graph<K, VV, EV> getUndirected() {

		DataSet<Edge<K, EV>> undirectedEdges = edges.
			flatMap(new RegularAndReversedEdgesMap<>()).name("To undirected graph");
		return new Graph<>(vertices, undirectedEdges, this.context);
	}
643020
public Graph<T> next() {
        if (nextSubgraphs.isEmpty()) 
            throw new NoSuchElementException();
        Graph<T> next = nextSubgraphs.poll();
        
        // If we've exhausted the current set of subgraphs, queue up more of
        // them, generated from the remaining vertices
        if (nextSubgraphs.isEmpty())
            advance();
        return next;
    }
648571
public function createGraphCloneEdgeless()
    {
        $graph = new Graph();
        $graph->getAttributeBag()->setAttributes($this->getAttributeBag()->getAttributes());
        // TODO: set additional graph attributes
        foreach ($this->getVertices() as $originalVertex) {
            $vertex = $graph->createVertexClone($originalVertex);
            // $graph->vertices[$vid] = $vertex;
        }

        return $graph;
    }
345089
def copy(self):
        
        other = DirectedGraph()
        other._vertices = set(self._vertices)
        other._forwards = {k: set(v) for k, v in self._forwards.items()}
        other._backwards = {k: set(v) for k, v in self._backwards.items()}
        return other
108379
public static String toDot(GraphvizGraph graph) {
    StringBuilder builder = new StringBuilder();
    builder.append(graph.isDirected() ? "digraph" : "graph");
    builder.append(INDENT);
    builder.append(graph.getName());
    builder.append(" {\n");
    builder.append(INDENT);
    builder.append("node [color=lightblue2, style=filled];\n");

    final String edgeSymbol = graph.isDirected() ? ARROW : LINE;

    List<GraphvizNode> nodes = graph.getGraphvizNodes();

    String[] nodeNames = new String[nodes.size()];

    for (int i = 0; i < nodeNames.length; i++) {
      GraphvizNode gNode = nodes.get(i);
      nodeNames[i] =
          gNode.getId()
              + " [label=\""
              + gNode.getLabel()
              + "\" color=\""
              + gNode.getColor()
              + "\"]";
    }

    // We sort the nodes so we get a deterministic output every time regardless
    // of the implementation of the graph data structure.
    Arrays.sort(nodeNames);

    for (String nodeName : nodeNames) {
      builder.append(INDENT);
      builder.append(nodeName);
      builder.append(";\n");
    }

    List<GraphvizEdge> edges = graph.getGraphvizEdges();

    String[] edgeNames = new String[edges.size()];

    for (int i = 0; i < edgeNames.length; i++) {
      GraphvizEdge edge = edges.get(i);
      edgeNames[i] = edge.getNode1Id() + edgeSymbol + edge.getNode2Id();
    }

    // Again, we sort the edges as well.
    Arrays.sort(edgeNames);

    for (String edgeName : edgeNames) {
      builder.append(INDENT);
      builder.append(edgeName);
      builder.append(";\n");
    }

    builder.append("}\n");
    return builder.toString();
  }
920969
public Graph<AttributeOccurrence>[] createDP() {
        Graph<AttributeOccurrence>[] dp;
        int i;
        int max;
        AttributionBuffer ab;

        dp = new Graph[semantics.getGrammar().getProductionCount()];
        for (i = 0; i < dp.length; i++) {
            dp[i] = new Graph<AttributeOccurrence>();
        }
        max = semantics.getSize();
        for (i = 0; i < max; i++) {
            ab = semantics.get(i);
            addDP(dp[ab.production], ab);
        }
        return dp;
    }
99222
def from_edges(edges):
        
        dag = DirectedGraph()
        for _u, _v in edges:
            dag.add_edge(_u, _v)
        return dag
657610
@Override
    public Iterator<?> downstreamProjects() {
        FlowRun flowRun = (FlowRun) build;

        DirectedGraph<JobInvocation, FlowRun.JobEdge> directedGraph = flowRun.getJobsGraph();

        return directedGraph.vertexSet().iterator();
    }
938999
public static int getEdgeKey(Graph graph, int edgeId, int node, boolean reverse) {
        EdgeIteratorState edgeIteratorState = graph.getEdgeIteratorState(edgeId, node);
        return GHUtility.createEdgeKey(edgeIteratorState.getBaseNode(), edgeIteratorState.getAdjNode(), edgeId, reverse);
    }
973754
public Set<T> types() {
        // NOTE: purely unoptimized!
        Set<T> types = new HashSet<T>();
        for (Object o : edges.values()) {
            Set<T> s = (Set<T>)o;
            types.addAll(s);
        }
        return types;
    }
110269
public static <T> Set<Set<Node<T>>> compute(final Graph<T> graph) {
    final Set<Set<Node<T>>> connectedComponents = new LinkedHashSet<>();
    final Set<Node<T>> unmarkedNodes = new LinkedHashSet<>(graph.nodes());

    while (!unmarkedNodes.isEmpty()) {
      Set<Node<T>> connectedComp = new LinkedHashSet<>();
      deepFirstSearch(unmarkedNodes.iterator().next(), connectedComp, unmarkedNodes);
      connectedComponents.add(connectedComp);
    }

    return connectedComponents;
  }
922337
public BiMap<V, K> inversed() {
        return (inverse == null) ? inverse = new BiMap<>(valueMap, keyMap) : inverse;
    }
252137
public Multigraph<T,E> next() {
        if (!hasNext())
            throw new NoSuchElementException();
        Multigraph<T,E> cur = next.poll();
        if (next.isEmpty())
            advance();
        return cur;
    }
381122
def add_undirected_edge(vertex_a, vertex_b, weight)
      add_edge(vertex_a, vertex_b, weight)
      add_edge(vertex_b, vertex_a, weight)
    end
749202
private List<Pair<Integer, Integer>> doGenerateEdgesSimpler() {
        final int numberOfNodes = getConfiguration().getNumberOfNodes();
        final long numberOfEdges = getConfiguration().getNumberOfEdges();

        final Set<Pair<Integer, Integer>> edges = new HashSet<>();

        while (edges.size() < numberOfEdges) {
            int origin = random.nextInt(numberOfNodes);
            int target = random.nextInt(numberOfNodes);

            if (target == origin) {
                continue;
            }

            edges.add(Pair.of(origin, target));
        }

        return new LinkedList<>(edges);
    }
127260
private List<PathEdge> combine(final List<PathEdge> edges, final int x) {

        final int n = edges.size();
        final List<PathEdge> reduced = new ArrayList<PathEdge>(n);

        for (int i = 0; i < n; i++) {
            PathEdge e = edges.get(i);
            for (int j = i + 1; j < n; j++) {
                PathEdge f = edges.get(j);
                if (e.disjoint(f)) reduced.add(new ReducedEdge(e, f, x));
            }
        }

        return reduced;
    }
550332
public Graph<Module> reduced() {
        Graph<Module> graph = build();
        // transitive reduction
        Graph<Module> newGraph = buildGraph(graph.edges()).reduce();

        if (DEBUG) {
            PrintWriter log = new PrintWriter(System.err);
            System.err.println("before transitive reduction: ");
            graph.printGraph(log);
            System.err.println("after transitive reduction: ");
            newGraph.printGraph(log);
        }

        return newGraph;
    }