public UndirectedGraph<Node, DefaultLink> getUndirectedGraph() { return new AsUndirectedGraph<>(this.gPrime); }
private void constructCategoryGraph(Wikipedia pWiki, DirectedGraph<Integer,DefaultEdge> pGraph) throws WikiApiException { this.wiki = pWiki; this.graph = pGraph; this.numberOfNodes = this.graph.vertexSet().size(); this.numberOfEdges = this.graph.edgeSet().size(); this.undirectedGraph = new AsUndirectedGraph<Integer, DefaultEdge>(this.graph); }
/** * Constructs a new BiconnectivityInspector * * @param graph the input graph */ public BiconnectivityInspector(Graph<V, E> graph) { this.graph = Objects.requireNonNull(graph); if (graph.getType().isDirected()) this.graph = new AsUndirectedGraph<>(graph); }
/** * Creates a connectivity inspector for the specified graph. * * @param g the graph for which a connectivity inspector to be created. */ public ConnectivityInspector(Graph<V, E> g) { init(); this.graph = Objects.requireNonNull(g); if (g.getType().isDirected()) this.graph = new AsUndirectedGraph<>(g); }
/** * Creates a weak chordality inspector for the {@code graph} * * @param graph the inspected {@code graph} */ public WeakChordalityInspector(Graph<V, E> graph) { this.graph = Objects.requireNonNull(graph); if (graph.getType().isDirected()) { this.graph = new AsUndirectedGraph<>(graph); } n = graph.vertexSet().size(); m = graph.edgeSet().size(); initMappings(); }
private DirectedWeightedMultigraph<Node, LabeledLink> computeSteinerTree(Set<Node> steinerNodes) { if (steinerNodes == null || steinerNodes.isEmpty()) { logger.error("There is no steiner node."); return null; } // System.out.println(steinerNodes.size()); List<Node> steinerNodeList = new ArrayList<>(steinerNodes); long start = System.currentTimeMillis(); UndirectedGraph<Node, DefaultLink> undirectedGraph = new AsUndirectedGraph<>(this.graphBuilder.getGraph()); logger.debug("computing steiner tree ..."); SteinerTree steinerTree = new SteinerTree(undirectedGraph, steinerNodeList); DirectedWeightedMultigraph<Node, LabeledLink> tree = new TreePostProcess(this.graphBuilder, steinerTree.getDefaultSteinerTree(), null, false).getTree(); //(DirectedWeightedMultigraph<Node, LabeledLink>)GraphUtil.asDirectedGraph(steinerTree.getDefaultSteinerTree()); logger.debug(GraphUtil.labeledGraphToString(tree)); long steinerTreeElapsedTimeMillis = System.currentTimeMillis() - start; logger.debug("total number of nodes in steiner tree: " + tree.vertexSet().size()); logger.debug("total number of edges in steiner tree: " + tree.edgeSet().size()); logger.debug("time to compute steiner tree: " + (steinerTreeElapsedTimeMillis/1000F)); return tree; // long finalTreeElapsedTimeMillis = System.currentTimeMillis() - steinerTreeElapsedTimeMillis; // DirectedWeightedMultigraph<Node, Link> finalTree = buildOutputTree(tree); // logger.info("time to build final tree: " + (finalTreeElapsedTimeMillis/1000F)); // GraphUtil.printGraph(finalTree); // return finalTree; }
/** * Get a new instance of the coloring algorithm based * * @param type a {@link Coloring} type * @param graph the graph to color. Will be converted to a undirected graph * @return a new instance of {@link VertexColoringAlgorithm} */ private static VertexColoringAlgorithm<String> getColoringAlgorithmInstance( Coloring type, Graph<String, DefaultEdge> graph) { AsUndirectedGraph<String, DefaultEdge> g = new AsUndirectedGraph<>(graph); switch (type) { case GREEDY: return new GreedyColoring<>(g); case RANDOM: return new RandomGreedyColoring<>(g); case SATURATION: default: return new SaturationDegreeColoring<>(g); } }
/** * Returns an undirected view of the specified graph. If the specified graph is directed, * returns an undirected view of it. If the specified graph is already undirected, just returns * it. * * @param g the graph for which an undirected view is to be returned * @param <V> the graph vertex type * @param <E> the graph edge type * * @return an undirected view of the specified graph, if it is directed, or or the specified * graph itself if it is already undirected. * * @throws IllegalArgumentException if the graph is neither directed nor undirected * @see AsUndirectedGraph */ public static <V, E> Graph<V, E> undirectedGraph(Graph<V, E> g) { if (g.getType().isDirected()) { return new AsUndirectedGraph<>(g); } else if (g.getType().isUndirected()) { return g; } else { throw new IllegalArgumentException("graph must be either directed or undirected"); } }
UndirectedGraph<Node, DefaultLink> undirectedGraph = new AsUndirectedGraph<>(this.getGraph());
/** * Creates a chordality inspector for {@code graph}, which uses an iterator defined by the * second parameter as an internal iterator. * * @param graph the graph for which a chordality inspector is to be created. * @param iterationOrder the constant, which defines iterator to be used by this * {@code ChordalityInspector}. */ public ChordalityInspector(Graph<V, E> graph, IterationOrder iterationOrder) { Objects.requireNonNull(graph); if (graph.getType().isDirected()) { this.graph = new AsUndirectedGraph<>(graph); } else { this.graph = graph; } this.iterationOrder = iterationOrder; this.hole = null; if (iterationOrder == IterationOrder.MCS) { this.orderIterator = new MaximumCardinalityIterator<>(graph); } else { this.orderIterator = new LexBreadthFirstIterator<>(graph); } }
new AsUndirectedGraph<>(this.graphBuilder.getGraph()), Lists.newLinkedList(sn.getNodes())); WeightedMultigraph<Node, DefaultLink> t = steinerTree.getDefaultSteinerTree(); TreePostProcess treePostProcess = new TreePostProcess(this.graphBuilder, t);
this.undirectedGraph = new AsUndirectedGraph<Integer, DefaultEdge>(this.graph);
new AsUndirectedGraph<>(treeModel); List<Node> steinerNodes = inputNodes; SteinerTree steinerTree = new SteinerTree(GraphUtil.asDefaultGraph(undirectedGraph), steinerNodes);