当前位置: 首页>>代码示例>>Java>>正文


Java DirectedOrderedSparseMultigraph类代码示例

本文整理汇总了Java中edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph的典型用法代码示例。如果您正苦于以下问题:Java DirectedOrderedSparseMultigraph类的具体用法?Java DirectedOrderedSparseMultigraph怎么用?Java DirectedOrderedSparseMultigraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DirectedOrderedSparseMultigraph类属于edu.uci.ics.jung.graph包,在下文中一共展示了DirectedOrderedSparseMultigraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUnreachabilitiyScenario

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
/**
 * @return There is only one shortest path! We have to prevent endless
 *         looping!
 */
public static KspTestScenario<String, MyLink> getUnreachabilitiyScenario() {
	Graph<String, MyLink> graph = new DirectedOrderedSparseMultigraph<String, MyLink>();

	String s = new String("S"); // the source
	graph.addVertex(s);
	String v = new String("V"); // the unreachable vertex!
	graph.addVertex(v);
	String w = new String("W"); // the intermediate vertex
	graph.addVertex(w);
	String t = new String("T"); // the target
	graph.addVertex(t);

	graph.addEdge(new MyLink(1, "S-V"), s, v, EdgeType.DIRECTED); // dead-end
	graph.addEdge(new MyLink(1, "S-W"), s, w, EdgeType.DIRECTED);
	graph.addEdge(new MyLink(1, "W-T"), w, t, EdgeType.DIRECTED);

	List<MyLink> path = new ArrayList<MyLink>();
	path.add(graph.findEdge(s, w));
	path.add(graph.findEdge(w, t));

	List<List<MyLink>> temp = new LinkedList<List<MyLink>>();
	temp.add(path);

	return new KspTestScenario<String, MyLink>(graph, temp, s, t);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:30,代码来源:KspTestScenarios.java

示例2: testUnreachable

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
@Test
public void testUnreachable() {
	Graph<String, MyLink> g = new DirectedOrderedSparseMultigraph<String, MyLink>();

	String n1 = new String("S"); // S
	g.addVertex(n1);
	String n2 = new String("A"); // A
	g.addVertex(n2);
	String n3 = new String("B"); // B -- not connected
	g.addVertex(n3);

	g.addEdge(new MyLink(1, "S-A"), n1, n2, EdgeType.DIRECTED); // S - A

	Transformer<MyLink, Number> weightTrans = new Transformer<MyLink, Number>() {
		@Override
		public Number transform(MyLink link) {
			return link.getWeight();
		}
	};
	SuurballeTarjan<String, MyLink> testMain = new SuurballeTarjan<String, MyLink>(
			g, weightTrans);
	assertEquals(null, testMain.getDisjointPaths(n1, n3));
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:24,代码来源:SuurballeTarjanTest.java

示例3: testNoDisjointSolution

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
@Test
public void testNoDisjointSolution() {
	Graph<String, MyLink> g = new DirectedOrderedSparseMultigraph<String, MyLink>();

	String n1 = new String("A"); // A
	g.addVertex(n1);
	String n2 = new String("B"); // B
	g.addVertex(n2);

	g.addEdge(new MyLink(2, "A-B"), n1, n2, EdgeType.DIRECTED);

	Transformer<MyLink, Number> weightTrans = new Transformer<MyLink, Number>() {
		@Override
		public Number transform(MyLink link) {
			return link.getWeight();
		}
	};
	SuurballeTarjan<String, MyLink> testMain = new SuurballeTarjan<String, MyLink>(
			g, weightTrans);
	assertEquals("[[A-B]]", testMain.getDisjointPaths(n1, n2).toString());
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:22,代码来源:SuurballeTarjanTest.java

示例4: reverseEdges

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
/**
 * This method reverse the path "path" in the graph "graph" and returns it.
 * 
 * @param graph
 *            the input graph which will not be changed.
 * @param path
 *            the path to reverse
 * @return a new graph with the reversed path
 */
private Graph<V, E> reverseEdges(Graph<V, E> graph, List<E> path) {
	if (graph == null || path == null)
		throw new IllegalArgumentException();
	Graph<V, E> clone = new DirectedOrderedSparseMultigraph<V, E>();

	for (V v : graph.getVertices())
		clone.addVertex(v);
	for (E e : graph.getEdges())
		clone.addEdge(e, graph.getEndpoints(e));

	for (E link : path) {
		V src = clone.getSource(link);
		V dst = clone.getDest(link);
		clone.removeEdge(link);
		clone.addEdge(link, dst, src, EdgeType.DIRECTED);
	}
	return clone;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:28,代码来源:SuurballeTarjan.java

示例5: getGraphFromLinkMap

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
/** <p>Obtains a {@code JUNG} graph from a given set of links.</p>
 * 
 * @param nodes Collection of nodes
 * @param links Collection of links
 * @return {@code JUNG} graph */
public static Graph<Node, Link> getGraphFromLinkMap(Collection<Node> nodes, Collection<Link> links)
{
	Graph<Node, Link> graph = new DirectedOrderedSparseMultigraph<Node, Link>();

	for (Node node : nodes)
		graph.addVertex(node);

	if (links != null)
	{
		for (Link e : links)
		{
			if (!graph.containsVertex(e.getOriginNode())) throw new RuntimeException("Bad"); //graph.addVertex(e.getOriginNode());
			if (!graph.containsVertex(e.getDestinationNode())) throw new RuntimeException("Bad"); //graph.addVertex(e.getDestinationNode());
			graph.addEdge(e, e.getOriginNode(), e.getDestinationNode());
		}
	}

	return graph;
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:25,代码来源:GraphUtils.java

示例6: reverseEdges

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
/** This method reverse the path "path" in the graph "graph" and returns it.
 * 
 * @param graph the input graph which will not be changed.
 * @param path the path to reverse
 * @return a new graph with the reversed path
 * @since 0.3.0 */
private static <V, E> Graph<V, E> reverseEdges(Graph<V, E> graph, List<E> path)
{
	if (graph == null || path == null) throw new IllegalArgumentException();
	Graph<V, E> clone = new DirectedOrderedSparseMultigraph<V, E>();

	for (V v : graph.getVertices())
		clone.addVertex(v);
	for (E e : graph.getEdges())
		clone.addEdge(e, graph.getEndpoints(e));

	for (E link : path)
	{
		V src = clone.getSource(link);
		V dst = clone.getDest(link);
		clone.removeEdge(link);
		clone.addEdge(link, dst, src, EdgeType.DIRECTED);
	}

	return clone;
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:27,代码来源:GraphUtils.java

示例7: readJUNGGraph

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
public static <V, E> Network readJUNGGraph(DirectedOrderedSparseMultigraph<V, E> graph, int modularityFunction) {
    StringBuilder stringBuilder = new StringBuilder();
    ArrayList<Object> vertices = new ArrayList<>(graph.getVertices());
    for (E edge : graph.getEdges()) {
        Pair<V> endpoints = graph.getEndpoints(edge);
        int firstVertex = vertices.indexOf(endpoints.getFirst());
        int secondVertex = vertices.indexOf(endpoints.getSecond());
        int smallerVertex, largerVertex;

        if (firstVertex > secondVertex) {
            smallerVertex = secondVertex;
            largerVertex = firstVertex;
        } else {
            smallerVertex = firstVertex;
            largerVertex = secondVertex;
        }
        stringBuilder.append(smallerVertex).append("\t").append(largerVertex).append("\n");
    }
    return readInputString(stringBuilder.toString(), modularityFunction);
}
 
开发者ID:deepminder,项目名称:SLM4J,代码行数:21,代码来源:ModularityOptimizer.java

示例8: getSimpleMultigraph

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
private static DirectedOrderedSparseMultigraph<String, String> getSimpleMultigraph() {
    DirectedOrderedSparseMultigraph<String, String> multigraph = new DirectedOrderedSparseMultigraph<>();
    Stream.of("A", "B", "C", "D", "E", "F").forEachOrdered(multigraph::addVertex);

    multigraph.addEdge("A->B", "A", "B");
    multigraph.addEdge("B->C", "B", "C");
    multigraph.addEdge("C->A", "C", "A");

    multigraph.addEdge("A->D", "A", "D");

    multigraph.addEdge("D->E", "D", "E");
    multigraph.addEdge("E->F", "E", "F");
    multigraph.addEdge("F->D", "F", "D");

    return multigraph;
}
 
开发者ID:deepminder,项目名称:SLM4J,代码行数:17,代码来源:JUNGTest.java

示例9: reverseEdges

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
/**
 * This method reverse the path "path" in the graph "graph" and returns it.
 *
 * @param graph the input graph which will not be changed.
 * @param path  the path to reverse
 * @return a new graph with the reversed path
 */
private Graph<V, E> reverseEdges(Graph<V, E> graph, List<E> path) {
    if (graph == null || path == null)
        throw new IllegalArgumentException();
    Graph<V, E> clone = new DirectedOrderedSparseMultigraph<V, E>();

    for (V v : graph.getVertices())
        clone.addVertex(v);
    for (E e : graph.getEdges())
        clone.addEdge(e, graph.getEndpoints(e));

    for (E link : path) {
        V src = clone.getSource(link);
        V dst = clone.getDest(link);
        clone.removeEdge(link);
        clone.addEdge(link, dst, src, EdgeType.DIRECTED);
    }
    return clone;
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:26,代码来源:SuurballeTarjan.java

示例10: getUnreachabilitiyScenario

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
/**
 * @return There is only one shortest path! We have to prevent endless
 * looping!
 */
public static KspTestScenario<String, MyLink> getUnreachabilitiyScenario() {
    Graph<String, MyLink> graph = new DirectedOrderedSparseMultigraph<String, MyLink>();

    String s = new String("S"); // the source
    graph.addVertex(s);
    String v = new String("V"); // the unreachable vertex!
    graph.addVertex(v);
    String w = new String("W"); // the intermediate vertex
    graph.addVertex(w);
    String t = new String("T"); // the target
    graph.addVertex(t);

    graph.addEdge(new MyLink(1, "S-V"), s, v, EdgeType.DIRECTED); // dead-end
    graph.addEdge(new MyLink(1, "S-W"), s, w, EdgeType.DIRECTED);
    graph.addEdge(new MyLink(1, "W-T"), w, t, EdgeType.DIRECTED);

    List<MyLink> path = new ArrayList<MyLink>();
    path.add(graph.findEdge(s, w));
    path.add(graph.findEdge(w, t));

    List<List<MyLink>> temp = new LinkedList<List<MyLink>>();
    temp.add(path);

    return new KspTestScenario<String, MyLink>(graph, temp, s, t);
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:30,代码来源:KspTestScenarios.java

示例11: testUnreachable

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
@Test
public void testUnreachable() {
    Graph<String, MyLink> g = new DirectedOrderedSparseMultigraph<String, MyLink>();

    String n1 = new String("S"); // S
    g.addVertex(n1);
    String n2 = new String("A"); // A
    g.addVertex(n2);
    String n3 = new String("B"); // B -- not connected
    g.addVertex(n3);

    g.addEdge(new MyLink(1, "S-A"), n1, n2, EdgeType.DIRECTED); // S - A

    Transformer<MyLink, Number> weightTrans = new Transformer<MyLink, Number>() {
        @Override
        public Number transform(MyLink link) {
            return link.getWeight();
        }
    };
    SuurballeTarjan<String, MyLink> testMain = new SuurballeTarjan<String, MyLink>(
            g, weightTrans);
    assertEquals(null, testMain.getDisjointPaths(n1, n3));
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:24,代码来源:SuurballeTarjanTest.java

示例12: testNoDisjointSolution

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
@Test
public void testNoDisjointSolution() {
    Graph<String, MyLink> g = new DirectedOrderedSparseMultigraph<String, MyLink>();

    String n1 = new String("A"); // A
    g.addVertex(n1);
    String n2 = new String("B"); // B
    g.addVertex(n2);

    g.addEdge(new MyLink(2, "A-B"), n1, n2, EdgeType.DIRECTED);

    Transformer<MyLink, Number> weightTrans = new Transformer<MyLink, Number>() {
        @Override
        public Number transform(MyLink link) {
            return link.getWeight();
        }
    };
    SuurballeTarjan<String, MyLink> testMain = new SuurballeTarjan<String, MyLink>(
            g, weightTrans);
    assertEquals("[[A-B]]", testMain.getDisjointPaths(n1, n2).toString());
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:22,代码来源:SuurballeTarjanTest.java

示例13: getLoopScenario

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
/**
 * @return There is only one shortest path! We have to prevent endless
 *         looping!
 */
public static KspTestScenario<String, MyLink> getLoopScenario() {
	Graph<String, MyLink> graph = new DirectedOrderedSparseMultigraph<String, MyLink>();

	String s = new String("S"); // the source
	graph.addVertex(s);
	String a = new String("A"); // the intermediate vertex 1
	graph.addVertex(a);
	String b = new String("B"); // the intermediate vertex 2
	graph.addVertex(b);
	String t = new String("T"); // the target
	graph.addVertex(t);

	graph.addEdge(new MyLink(1, "S-A"), s, a, EdgeType.DIRECTED);
	graph.addEdge(new MyLink(1, "A-B"), a, b, EdgeType.DIRECTED);
	graph.addEdge(new MyLink(1, "B-A"), b, a, EdgeType.DIRECTED); // loop!
	graph.addEdge(new MyLink(1, "B-T"), b, t, EdgeType.DIRECTED);

	List<MyLink> path = new ArrayList<MyLink>();
	path.add(graph.findEdge(s, a));
	path.add(graph.findEdge(a, b));
	path.add(graph.findEdge(b, t));

	List<List<MyLink>> temp = new LinkedList<List<MyLink>>();
	temp.add(path);

	return new KspTestScenario<String, MyLink>(graph, temp, s, t);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:32,代码来源:KspTestScenarios.java

示例14: getSelfLoopUnreachableScenario

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
/**
 * @return Self-loop at start and unreachable target.
 */
public static KspTestScenario<String, MyLink> getSelfLoopUnreachableScenario() {
	Graph<String, MyLink> graph = new DirectedOrderedSparseMultigraph<String, MyLink>();

	String s = new String("S"); // the source
	graph.addVertex(s);
	String t = new String("T");
	graph.addVertex(t);

	graph.addEdge(new MyLink(20, "S-S"), s, s, EdgeType.DIRECTED); // loop

	List<List<MyLink>> temp = new LinkedList<List<MyLink>>();

	return new KspTestScenario<String, MyLink>(graph, temp, s, t);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:18,代码来源:KspTestScenarios.java

示例15: constructorTest2

import edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void constructorTest2() {
	Graph<String, MyLink> g = new DirectedOrderedSparseMultigraph<String, MyLink>();
	Transformer<MyLink, Number> weightTrans = null;

	new SuurballeTarjan<String, MyLink>(g, weightTrans);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:8,代码来源:SuurballeTarjanTest.java


注:本文中的edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。