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


Java DirectedSparseMultigraph类代码示例

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


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

示例1: setup

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
@Override
public void setup() {
	this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
	this.edgeWeights = new HashMap<Edge, Number>();
	this.edgeFactory = new Factory<Integer>() {
		int i = 0;

		public Integer create() {
			return i++;
		}
	};

	this.disambiguatedSurfaceForms = new BitSet(repList.size());
	for (int i = 0; i < repList.size(); i++) {
		if (repList.get(i).getCandidates().size() <= 1) {
			this.disambiguatedSurfaceForms.set(i);
		}
	}
	buildMainGraph();
}
 
开发者ID:quhfus,项目名称:DoSeR-Disambiguation,代码行数:21,代码来源:FinalEntityDisambiguatorGeneral.java

示例2: setup

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
@Override
public void setup() {
	this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
	this.edgeWeights = new HashMap<Edge, Number>();
	this.edgeFactory = new Factory<Integer>() {
		int i = 0;

		public Integer create() {
			return i++;
		}
	};

	for (SurfaceForm sf : repList) {
		SurfaceForm clone = (SurfaceForm) sf.clone();
		this.origList.add(clone);
	}

	this.disambiguatedSurfaceForms = new BitSet(repList.size());
	for (int i = 0; i < repList.size(); i++) {
		if (repList.get(i).getCandidates().size() <= 1) {
			this.disambiguatedSurfaceForms.set(i);
		}
	}
	buildMainGraph();
}
 
开发者ID:quhfus,项目名称:DoSeR-Disambiguation,代码行数:26,代码来源:Word2VecDisambiguatorGeneral.java

示例3: setup

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
@Override
	public void setup() {
		this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
		this.edgeWeights = new HashMap<Edge, Number>();
		this.edgeFactory = new Factory<Integer>() {
			int i = 0;

			public Integer create() {
				return i++;
			}
		};

//		List<SurfaceForm> list = new LinkedList<SurfaceForm>();
//		for (SurfaceForm r : this.repList) {
//			list.add((SurfaceForm) r.clone());
//		}
//		Collections.sort(list);
//		this.repList = list;
		this.disambiguatedSurfaceForms = new BitSet(repList.size());
		for (int i = 0; i < repList.size(); i++) {
			if (repList.get(i).getCandidates().size() <= 1) {
				this.disambiguatedSurfaceForms.set(i);
			}
		}
		buildMainGraph();
	}
 
开发者ID:quhfus,项目名称:DoSeR-Disambiguation,代码行数:27,代码来源:FinalEntityDisambiguation.java

示例4: setup

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public void setup() {
	this.graph = new DirectedSparseMultigraph<Vertex, Edge>();
	this.edgeWeights = new HashMap<Edge, Number>();
	this.edgeFactory = new Factory<Integer>() {
		int i = 0;

		public Integer create() {
			return i++;
		}
	};

	List<SurfaceForm> list = new LinkedList<SurfaceForm>();
	for (SurfaceForm r : this.repList) {
		list.add((SurfaceForm) r.clone());
	}
	Collections.sort(list);
	this.repList = list;
	this.disambiguatedSurfaceForms = new BitSet(repList.size());
	for (int i = 0; i < repList.size(); i++) {
		if (repList.get(i).getCandidates().size() <= 1) {
			this.disambiguatedSurfaceForms.set(i);
		}
	}
	buildMainGraph();
}
 
开发者ID:quhfus,项目名称:DoSeR-Disambiguation,代码行数:26,代码来源:AbstractWord2VecPageRank.java

示例5: StateVisualizer

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public StateVisualizer() {
    super("Model Visualizer");
    graph = new DirectedSparseMultigraph<>();
    graph.addVertex(current);
//    Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph);
    layout = new KKLayout<>(graph);
    layout.setSize(new Dimension(800, 600)); // sets the initial size of the space
    vv = new VisualizationViewer<>(layout);
    vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    VertexLabelAsShapeRenderer<String, StepCounter> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
//    vv.getRenderContext().setVertexShapeTransformer(vlasr);
    vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer());
//    vv.getRenderContext().setVertexLabelRenderer(new TransitionVertextLabelRenderer(Color.GREEN));
    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.addKeyListener(gm.getModeKeyListener());
    gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    vv.setGraphMouse(gm);
    getContentPane().add(vv);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(1024, 768);
    pack();
    setVisible(true);
  }
 
开发者ID:mukatee,项目名称:osmo,代码行数:27,代码来源:StateVisualizer.java

示例6: FSMBuildVisualizer

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public FSMBuildVisualizer() {
    super("Model Visualizer");
    graph = new DirectedSparseMultigraph<>();
    graph.addVertex(current);
//    Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph);
    layout = new KKLayout<>(graph);
    layout.setSize(new Dimension(800, 600)); // sets the initial size of the space
    vv = new VisualizationViewer<>(layout);
    vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    VertexLabelAsShapeRenderer<String, StepCounter> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
//    vv.getRenderContext().setVertexShapeTransformer(vlasr);
    vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer());
//    vv.getRenderContext().setVertexLabelRenderer(new TransitionVertextLabelRenderer(Color.GREEN));
    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.addKeyListener(gm.getModeKeyListener());
    gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    vv.setGraphMouse(gm);
    getContentPane().add(vv);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(1024, 768);
    pack();
    setVisible(true);
  }
 
开发者ID:mukatee,项目名称:osmo,代码行数:27,代码来源:FSMBuildVisualizer.java

示例7: build

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public static DirectedGraph<GraphNode, GraphEdge> build(
    GraphModel graphModel, EdgeMatcher<String> matcher) {

  DirectedGraph<GraphNode, GraphEdge> result =
          new DirectedSparseMultigraph<GraphNode, GraphEdge>();

  Set<GraphNode> includedNodes = graphModel.getNodesSet();

  for (GraphEdge edge : graphModel.getEdges()) {
    // Filter on nodes first
    if (!includedNodes.contains(edge.getHead()))
      continue;

    if (!includedNodes.contains(edge.getTail()))
      continue;

    if (matcher.edgeForward(edge)) {
      result.addEdge(edge, edge.getHead(), edge.getTail());
    }
    else if (matcher.edgeReverse(edge)) {
      result.addEdge(edge, edge.getTail(), edge.getHead());
    }
  }
  return result;
}
 
开发者ID:google,项目名称:depan,代码行数:26,代码来源:JungBuilder.java

示例8: randomERGraph

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public static DirectedSparseMultigraph<Node,Edge> randomERGraph(int n, double p, RandomDataImpl rand){
	DirectedSparseMultigraph<Node,Edge> ans = new DirectedSparseMultigraph<Node,Edge>();
	Node[] nodes = new Node[n];
	for(int i =0; i < n; i++){
		nodes[i] = new Node(""+i);
		ans.addVertex(nodes[i]);
	}
	for(int i = 0; i < n; i++){
		int numNeighbors = rand.nextBinomial(n,p);
		if(numNeighbors> 0){
			Object[] neighborNodes = rand.nextSample(Arrays.asList(nodes), numNeighbors);
			for(Object neighborNodeO: neighborNodes){
				Node neighborNode = (Node)neighborNodeO;
				if(nodes[i] != neighborNode){
					ans.addEdge(new Edge(nodes[i].toString()+"-"+neighborNode.toString()),nodes[i],neighborNode);					
				}				
			}
		}
	}
	return ans;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:22,代码来源:RandomGraphFactory.java

示例9: MaximumWeightedPacking

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public MaximumWeightedPacking(
    AuxiliaryInputStatistics<V, E> auxilaryInputStatistics,
    final Set<V> pairedNodes, final DirectedSparseMultigraph<V, E> graph,
    double cycleBonus, final double defaultEdgeWeight,
    final PairMatchPowerBonus pairMatchPowerBonus) {
  super();

  this.auxiliaryInputStatistics = auxilaryInputStatistics;
  this.pairedNodes = pairedNodes;
  this.graph = graph;
  this.cycleBonus = cycleBonus;
  this.defaultEdgeWeight = defaultEdgeWeight;
  this.pairMatchPowerBonus = pairMatchPowerBonus;
  this.edgeWeights = new Function<E, Double>() {
    @Override
    public Double apply(E edge) {
      double val = defaultEdgeWeight;
      if (pairedNodes.contains(graph.getDest(edge))) {
        val += pairMatchPowerBonus
            .edgeBonusForReceiverPairMatchPower(getPairMatchPower(graph
                .getDest(edge)));
      }
      return val;
    }
  };
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:27,代码来源:MaximumWeightedPacking.java

示例10: MultiPeriodCyclePackingInputs

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public MultiPeriodCyclePackingInputs(
    DirectedSparseMultigraph<VV, EE> graph, Set<VV> chainRoots,
    Set<VV> terminalNodes, TimeInstant<TT> startTime,
    TimeInstant<TT> endTime,
    ImmutableMap<VV, TimeInstant<TT>> nodeArrivalTimes,
    ImmutableMap<EE, TimeInstant<TT>> edgeArrivalTimes,
    TimeWriter<TT> timeWriter) {
  super();
  this.graph = graph;
  this.chainRoots = chainRoots;
  this.terminalNodes = terminalNodes;
  this.paired = new HashSet<VV>(graph.getVertices());
  paired.removeAll(chainRoots);
  paired.removeAll(terminalNodes);
  this.startTime = startTime;
  this.endTime = endTime;
  this.nodeArrivalTimes = nodeArrivalTimes;
  this.edgeArrivalTimes = edgeArrivalTimes;
  this.timeWriter = timeWriter;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:21,代码来源:MultiPeriodCyclePacking.java

示例11: CycleVariables

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public CycleVariables(DirectedSparseMultigraph<V,E> graph, 
		List<EdgeCycle<E>> cycles, IloCplex cplex) throws IloException{
	super(new HashSet<EdgeCycle<E>>(cycles),cplex);
	if(super.size() != cycles.size()){
		throw new RuntimeException("cycles contained a duplicate");
	}
	this.graph = graph;
	
	ImmutableListMultimap.Builder<E,EdgeCycle<E>> edgeBuilder = ImmutableListMultimap.builder();
	ImmutableListMultimap.Builder<V,EdgeCycle<E>> nodeBuilder = ImmutableListMultimap.builder();
	for(EdgeCycle<E> cycle: cycles){
		for(E edge: cycle.getEdgesInOrder()){
			edgeBuilder.put(edge, cycle);
			nodeBuilder.put(graph.getSource(edge),cycle);
		}
	}
	nodeToCycles =nodeBuilder.build();
	edgeToCycles = edgeBuilder.build();
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:20,代码来源:CycleVariables.java

示例12: findConnectedComponentCuts

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public List<CycleCut<E>> findConnectedComponentCuts(double minimumViolation){
	EdgePredicateFilter<V,E> filter = new EdgePredicateFilter<V,E>(new Predicate<E>(){
		@Override
		public boolean evaluate(E edge) {
			if(nonZeroEdgeWeights.containsKey(edge)){
				return Math.abs(1-nonZeroEdgeWeights.get(edge)) < CplexUtil.epsilon;
			}
			return false;				
		}});
	DirectedSparseMultigraph<V,E> integerOnlyGraph = (DirectedSparseMultigraph<V,E>)filter.transform(graph);
	WeakComponentClusterer<V,E> clusterer = new WeakComponentClusterer<V,E>();
	Set<Set<V>> connectedComponents = clusterer.transform(integerOnlyGraph);
	List<CycleCut<E>> ans = new ArrayList<CycleCut<E>>();
	for(Set<V> component: connectedComponents){
		if(GraphUtil.testSetIsCycle(component,integerOnlyGraph) && component.size() >= this.minCycleEdgesToSeparate){
			EdgeCycle<E> cycle = GraphUtil.makeCycle(component, integerOnlyGraph);
			ans.add(new CycleCut<E>(cycle,cycle.size(),1));
		}
	}
	return ans;		
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:22,代码来源:CycleSeparator.java

示例13: checkFractionalSolution

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
/**
 * 
 * @param nonZeroEdgeValues
 * @return A list of lists of length 3. A returned list of [u,v,w] indicates
 *         that the constraint delta_uv + delta_vw <= delta_uw + 1 should be
 *         added.
 */
public List<List<V>> checkFractionalSolution(
    Map<E, Double> nonZeroEdgeValues,
    ImmutableTable<V, V, Double> precVarVals) {
  Set<V> retainedVertices = Sets.newHashSet(kepInstance.getGraph()
      .getVertices());
  Set<E> retainedEdges = Maps.filterValues(nonZeroEdgeValues,
      Range.<Double> atLeast(.51)).keySet();
  // In the below graph, each node will have in degree and out degree
  // at most one
  DirectedSparseMultigraph<V, E> inUseEdges = SubgraphUtil.subgraph(
      kepInstance.getGraph(), retainedVertices, retainedEdges);
  CycleChainDecomposition<V, E> decomposition = new CycleChainDecomposition<V, E>(
      inUseEdges);
  List<List<V>> ans = checkCycleChainDecomposition(decomposition,
      precVarVals, checkChains);
  fractionalCutsAdded += ans.size();
  return ans;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:26,代码来源:MinWaitingTimeKepSolver.java

示例14: GraphPanel

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public GraphPanel(DirectedSparseMultigraph<V, E> graph) {
  // this.setLayout(new FlowLayout());
  DirectedSparseMultigraph<V, E> graphTemp = new DirectedSparseMultigraph<V, E>();
  for (V vertex : graph.getVertices()) {
    if (graph.inDegree(vertex) > 0 || graph.outDegree(vertex) > 0) {
      graphTemp.addVertex(vertex);
    }
  }
  for (E edge : graph.getEdges()) {
    if (graphTemp.containsVertex(graph.getSource(edge))
        && graphTemp.containsVertex(graph.getDest(edge))) {
      graphTemp.addEdge(edge, graph.getSource(edge), graph.getDest(edge));
    }
  }
  this.graph = graphTemp;
  layout = new KKLayout<V, E>(this.graph);
  layout.setSize(new Dimension(1000, 800)); // sets the initial size of the
                                            // space
  // The BasicVisualizationServer<V,E> is parameterized by the edge types
  BasicVisualizationServer<V, E> server = new BasicVisualizationServer<V, E>(
      layout);
  server.setPreferredSize(new Dimension(1000, 800));
  this.add(server);

}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:26,代码来源:GraphPanel.java

示例15: createRestrictedProblem

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入依赖的package包/类
public KepInstance<V, E> createRestrictedProblem(Set<E> retainedEdges) {
  DirectedSparseMultigraph<V, E> subgraph = GraphUtil.makeSubgraph(
      this.getGraph(), retainedEdges);

  KepInstance<V, E> ans = new KepInstance<V, E>(subgraph,
      this.kepProblemData.getRootNodes(),
      this.kepProblemData.getPairedNodes(),
      this.kepProblemData.getTerminalNodes(), edgeWeights, maxChainLength,
      maxCycleLength, cycleBonus);
  ans.getBridgeConstraints().addAll(bridgeConstraints);
  ans.getNodeFlowInConstraints().addAll(nodeFlowInConstraints);
  ans.getNodeFlowOutConstraints().addAll(nodeFlowOutConstraints);
  for (EdgeConstraint<E> edgeConstraint : edgeUsageConstraints) {
    ans.getEdgeUsageConstraints().add(
        new EdgeConstraint<E>(Sets.intersection(edgeConstraint.getEdges(),
            retainedEdges), edgeConstraint.getCoefficients(), edgeConstraint
            .getRelationType(), edgeConstraint.getRhs()));
  }
  return ans;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:21,代码来源:KepInstance.java


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