• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StrongConnectivityInspector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getCycleComponents

import org.jgrapht.alg.StrongConnectivityInspector; //导入依赖的package包/类
/**
 * Returns the components of the graph that are cycles.
 * Taken from the implementation of {@link CycleDetector#findCycles()}. (EPL)
 */
private static <T, E> ListIterable<Set<T>> getCycleComponents(final DirectedGraph<T, E> graph) {
    StrongConnectivityInspector<T, E> inspector =
            new StrongConnectivityInspector<T, E>(graph);

    return ListAdapter.adapt(inspector.stronglyConnectedSets()).select(new Predicate<Set<T>>() {
        @Override
        public boolean accept(Set<T> each) {
            if (each.size() > 1) {
                // multi-vertex strongly-connected component is a cycle
                return true;
            }

            // vertex with an edge to itself is a cycle
            T vertex = each.iterator().next();
            return graph.containsEdge(vertex, vertex);
        }
    });
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:23,代码来源:GraphUtil.java


示例2: getAverageTwoTermReliability

import org.jgrapht.alg.StrongConnectivityInspector; //导入依赖的package包/类
/**
 * Returns the average two-term reliability (A2TR) of the network. A2TR is computed
 * as the ratio between the number of node-pair for which a path can be found
 * and the same number when the network is connected (<i>Nx(N-1)</i>, where
 * <i>N</i> is the number of nodes in the network). The value is in range [0, 1].
 *
 * @return Average two-term reliability
 */
public double getAverageTwoTermReliability()
{
	if (E == 0) return 0;

	DirectedGraph<Node, Link> graph = getGraph_JGraphT();
	StrongConnectivityInspector<Node, Link> ci = new StrongConnectivityInspector<Node, Link>(graph);
	List<Set<Node>> connectedComponents = ci.stronglyConnectedSets();

	double sum = 0;
	Iterator<Set<Node>> it = connectedComponents.iterator();
	while (it.hasNext())
	{
		int componentSize = it.next().size();
		sum += componentSize * (componentSize - 1);
	}

	return sum / (N * (N - 1));
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:27,代码来源:GraphTheoryMetrics.java


示例3: getStronglyConnectedComponents

import org.jgrapht.alg.StrongConnectivityInspector; //导入依赖的package包/类
/**
 * Constructs a list of NFA graphs each representing a strongly connected
 * component in the graph given as parameter.
 * 
 * @param m
 *            The NFA graph to find the strongly connected components in.
 * @return A list containing all the strongly connected components.
 * @throws InterruptedException 
 */
public static LinkedList<NFAGraph> getStronglyConnectedComponents(NFAGraph m) throws InterruptedException {
	StrongConnectivityInspector<NFAVertexND, NFAEdge> sci = new StrongConnectivityInspector<NFAVertexND, NFAEdge>(m);
	List<DirectedSubgraph<NFAVertexND, NFAEdge>> sccs = sci.stronglyConnectedSubgraphs();
	LinkedList<NFAGraph> sccNFAs = new LinkedList<NFAGraph>();

	for (DirectedSubgraph<NFAVertexND, NFAEdge> scc : sccs) {
		if (isInterrupted()) {
			throw new InterruptedException();
		}

		/* scc's consisting of no edges are irrelevant for our purpose */
		if (scc.edgeSet().size() > 0) {

			NFAGraph currentNFAG = new NFAGraph();
			for (NFAVertexND v : scc.vertexSet()) {
				if (isInterrupted()) {
					throw new InterruptedException();
				}
				currentNFAG.addVertex(v);
			}
			for (NFAEdge e : scc.edgeSet()) {
				if (isInterrupted()) {
					throw new InterruptedException();
				}
				currentNFAG.addEdge(e);
			}

			sccNFAs.add(currentNFAG);
		}

	}
	return sccNFAs;
}
 
开发者ID:NicolaasWeideman,项目名称:RegexStaticAnalysis,代码行数:43,代码来源:NFAAnalysisTools.java


示例4: generate

import org.jgrapht.alg.StrongConnectivityInspector; //导入依赖的package包/类
public DependencyStratification generate(List<Dependency> dependencies, EGTask task) {
    Map<Dependency, Set<AttributeRef>> affectedAttributes = findAllAffectedAttributes(dependencies, task);
    if (logger.isDebugEnabled()) logger.debug("Affected attributes: " + SpeedyUtility.printMap(affectedAttributes));
    Map<Dependency, Set<AttributeRef>> queriedAttributes = findAllQueriedAttributes(dependencies, task);
    if (logger.isDebugEnabled()) logger.debug("Queried attributes: " + SpeedyUtility.printMap(queriedAttributes));
    DirectedGraph<Dependency, DefaultEdge> dependencyGraph = initDependencyGraph(dependencies, affectedAttributes, queriedAttributes);
    if (logger.isDebugEnabled()) logger.debug("Dependency graph: \n" + dependencyGraph);
    StrongConnectivityInspector<Dependency, DefaultEdge> connectivityInstector = new StrongConnectivityInspector<Dependency, DefaultEdge>(dependencyGraph);
    List<Set<Dependency>> strata = connectivityInstector.stronglyConnectedSets();
    Collections.sort(strata, new StratumComparator(dependencyGraph));
    return new DependencyStratification(strata);
}
 
开发者ID:dbunibas,项目名称:BART,代码行数:13,代码来源:GenerateStratification.java


示例5: getTopologicallyOrderedMappingConfigurations

import org.jgrapht.alg.StrongConnectivityInspector; //导入依赖的package包/类
private List<MappingConfiguration> getTopologicallyOrderedMappingConfigurations(
		JsonixContext context,
		final List<ModuleConfiguration> moduleConfigurations) {
	final DirectedGraph<MappingConfiguration, Object> mappingConfigurationDependencyGraph = buildMappingConfigurationDependencyGraph(
			context, moduleConfigurations);

	final StrongConnectivityInspector<MappingConfiguration, Object> strongConnectivityInspector = new StrongConnectivityInspector<MappingConfiguration, Object>(
			mappingConfigurationDependencyGraph);

	final List<Set<MappingConfiguration>> stronglyConnectedSets = strongConnectivityInspector
			.stronglyConnectedSets();

	for (Set<MappingConfiguration> stronglyConnectedSet : stronglyConnectedSets) {
		if (stronglyConnectedSet.size() > 1) {
			throw new IllegalArgumentException(MessageFormat.format(
					"Mappings have the following dependency cycle: {0}",
					stronglyConnectedSet.toString()));
		}
	}

	final List<MappingConfiguration> mappingConfigurations = new ArrayList<MappingConfiguration>(
			mappingConfigurationDependencyGraph.vertexSet().size());
	for (Iterator<MappingConfiguration> mappingConfigurationsInTopologicalOrderIterator = new TopologicalOrderIterator<MappingConfiguration, Object>(
			mappingConfigurationDependencyGraph); mappingConfigurationsInTopologicalOrderIterator
			.hasNext();) {
		mappingConfigurations
				.add(mappingConfigurationsInTopologicalOrderIterator.next());
	}
	return mappingConfigurations;
}
 
开发者ID:highsource,项目名称:jsonix-schema-compiler,代码行数:31,代码来源:ModulesConfiguration.java


示例6: getTheLargestGraphComponent

import org.jgrapht.alg.StrongConnectivityInspector; //导入依赖的package包/类
private Set<Long> getTheLargestGraphComponent(
		StrongConnectivityInspector<Long, PlannerEdge> strongConnectivityInspector) {
	List<Set<Long>> components = strongConnectivityInspector.stronglyConnectedSets();
	Collections.sort(components, new Comparator<Set<Long>>() {

		@Override
		public int compare(Set<Long> o1, Set<Long> o2) {
			return o2.size() - o1.size();
		}

	});

	return components.get(0);
}
 
开发者ID:agents4its,项目名称:mobilitytestbed,代码行数:15,代码来源:NodeDensityMapInit.java


示例7: connectivity

import org.jgrapht.alg.StrongConnectivityInspector; //导入依赖的package包/类
private Graph<Node, Edge> connectivity(Graph graph) {

		DirectedGraph<Long, PlannerEdge> plannerGraph = prepareGraphForFindComponents(graph);

		StrongConnectivityInspector<Long, PlannerEdge> strongConnectivityInspector = new StrongConnectivityInspector<>(
				plannerGraph);

		if (strongConnectivityInspector.isStronglyConnected()) {
			return graph;
		}

		LOGGER.debug("The Highway map has more then one strong component, it will be selected the largest components");

		Set<Long> strongestComponents = getTheLargestGraphComponent(strongConnectivityInspector);

		return createGraphBasedOnTheLargestComponent(graph, strongestComponents);
	}
 
开发者ID:agents4its,项目名称:mobilitytestbed,代码行数:18,代码来源:NodeDensityMapInit.java


示例8: isIrreducible

import org.jgrapht.alg.StrongConnectivityInspector; //导入依赖的package包/类
@Override
public boolean isIrreducible() {
	
	StrongConnectivityInspector<Integer, DefaultEdge> tmpSCI = new StrongConnectivityInspector<>(this.internalGraph);
	
	return tmpSCI.isStronglyConnected();
}
 
开发者ID:andreaboccaccio,项目名称:jMyCTMC,代码行数:8,代码来源:MyCTMC.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebSecurityExpressionRoot类代码示例发布时间:2022-05-22
下一篇:
Java GroupedStackedBarRenderer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap