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


Java DirectedSparseGraph.addVertex方法代码示例

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


在下文中一共展示了DirectedSparseGraph.addVertex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matrixToGraph

import edu.uci.ics.jung.graph.DirectedSparseGraph; //导入方法依赖的package包/类
public static DirectedSparseGraph<Vertex, Edge> matrixToGraph(double[][] matrix){
	DirectedSparseGraph<Vertex, Edge> graph = new DirectedSparseGraph<Vertex,Edge>();
	if(matrix.length != matrix[0].length){
		return null;
	}
	
	Vertex[] vertices = new Vertex[matrix.length];
	for (int i = 0; i < vertices.length; i++) {
		vertices[i] = new Vertex(i);
		graph.addVertex(vertices[i]);
	}
	
	for (int i = 0; i < matrix.length; i++) {
		for (int j = 0; j < matrix[i].length; j++) {
			if(matrix[i][j] != 0.0){
				Edge edge = new Edge();
				graph.addEdge(edge,vertices[i], vertices[j]);
			}
		}
	}
	return graph;
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:23,代码来源:Conversion.java

示例2: addNodeToGraph

import edu.uci.ics.jung.graph.DirectedSparseGraph; //导入方法依赖的package包/类
public void addNodeToGraph(DirectedSparseGraph<Node, String> graph, HashMap<String, Node> nodes,
		NamedEntityInText entity, Triple c, String candidateURL) throws IOException {
	Node currentNode = new Node(candidateURL, 0, 0, algorithm);
	log.debug("CandidateURL: " + candidateURL);
	// candidates are connected to a specific label in the text via their
	// start position
	if (!graph.addVertex(currentNode)) {
		int st = entity.getStartPos();
		if (nodes.get(candidateURL) != null) {
			nodes.get(candidateURL).addId(st);
		} else {
			log.error("This vertex couldn't be added because of an bug in Jung: " + candidateURL);
		}
	} else {
		currentNode.addId(entity.getStartPos());
		nodes.put(candidateURL, currentNode);
	}
}
 
开发者ID:dice-group,项目名称:AGDISTIS,代码行数:19,代码来源:CandidateUtil.java

示例3: addNodeToGraph

import edu.uci.ics.jung.graph.DirectedSparseGraph; //导入方法依赖的package包/类
public void addNodeToGraph(final DirectedSparseGraph<Node, String> graph,
    final HashMap<String, Node> nodes, final NamedEntityInText entity, final Triple c,
    final String candidateURL) throws IOException {
  final Node currentNode = new Node(candidateURL, 0, 0, algorithm);
  log.debug("CandidateURL: " + candidateURL);
  // candidates are connected to a specific label in the text via their
  // start position
  if (!graph.addVertex(currentNode)) {
    final int st = entity.getStartPos();
    if (nodes.get(candidateURL) != null) {
      nodes.get(candidateURL).addId(st);
    } else {
      log.error("This vertex couldn't be added because of an bug in Jung: " + candidateURL);
    }
  } else {
    currentNode.addId(entity.getStartPos());
    nodes.put(candidateURL, currentNode);
  }
}
 
开发者ID:dice-group,项目名称:FOX,代码行数:20,代码来源:CandidateUtil.java

示例4: main

import edu.uci.ics.jung.graph.DirectedSparseGraph; //导入方法依赖的package包/类
public static void main(String[] args) {
  DirectedSparseGraph<String, String> g = new DirectedSparseGraph<String, String>();
  g.addVertex("Square");
  g.addVertex("Rectangle");
  g.addVertex("Circle");
  g.addEdge("Edge1", "Square", "Rectangle");
  g.addEdge("Edge2", "Square", "Circle");
  g.addEdge("Edge3", "Circle", "Square");
  
  VisualizationViewer<String, String> vv =
    new VisualizationViewer<String, String>(
      new FRLayout<String, String>(g), new Dimension(400,400));
  Transformer<String, String> transformer = new Transformer<String, String>() {
    @Override public String transform(String arg0) { return arg0; }
  };
  vv.getRenderContext().setVertexLabelTransformer(transformer);
  transformer = new Transformer<String, String>() {
    @Override public String transform(String arg0) { return arg0; }
  };
  vv.getRenderContext().setEdgeLabelTransformer(transformer);
  vv.getRenderer().setVertexRenderer(new MyRenderer());
 
  // The following code adds capability for mouse picking of vertices/edges. Vertices can even be moved!
  final DefaultModalGraphMouse<String,Number> graphMouse = new DefaultModalGraphMouse<String,Number>();
  vv.setGraphMouse(graphMouse);
  graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
 
  JFrame frame = new JFrame();
  frame.getContentPane().add(vv);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.pack();
  frame.setVisible(true);
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:34,代码来源:VertexShapes.java

示例5: getJungGraph

import edu.uci.ics.jung.graph.DirectedSparseGraph; //导入方法依赖的package包/类
/**
 * This method creates a graph representation of a concept used to visualize it via JUNG library
 * @return
 */
public DirectedSparseGraph<Node, String> getJungGraph()
{
	DirectedSparseGraph<Node, String> graph = new DirectedSparseGraph<Node, String>();
	
	graph.addVertex(this);
	
	OutLinkElement outLink = _lastOutLink;

	while (outLink != null)
	{
		graph.addVertex(outLink.relation);
		
		graph.addEdge(getNextEdgeLabelId(), this, outLink.relation, EdgeType.DIRECTED);
		
		graph.addVertex(outLink.relation.referent);
		
		graph.addEdge(getNextEdgeLabelId(), outLink.relation, outLink.relation.referent, EdgeType.DIRECTED);
		
		outLink = outLink.previousOutLinkElement;
	}
	
	InLinkElement inLink = _lastInLink;

	while (inLink != null)
	{
		graph.addVertex(inLink.relation);
		
		graph.addEdge(getNextEdgeLabelId(), inLink.relation, this, EdgeType.DIRECTED);
		
		graph.addVertex(inLink.relation.argument);
		
		graph.addEdge(getNextEdgeLabelId(), inLink.relation.argument, inLink.relation, EdgeType.DIRECTED);
		
		inLink = inLink.previousInLinkElement;
	}
			
	return graph;
}
 
开发者ID:darrudi,项目名称:HPR,代码行数:43,代码来源:Node.java


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