當前位置: 首頁>>代碼示例>>Java>>正文


Java EdgeType.DIRECTED屬性代碼示例

本文整理匯總了Java中edu.uci.ics.jung.graph.util.EdgeType.DIRECTED屬性的典型用法代碼示例。如果您正苦於以下問題:Java EdgeType.DIRECTED屬性的具體用法?Java EdgeType.DIRECTED怎麽用?Java EdgeType.DIRECTED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在edu.uci.ics.jung.graph.util.EdgeType的用法示例。


在下文中一共展示了EdgeType.DIRECTED屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getGraph

/**
 * Convert FNSS topology to JUNG graph.
 * 
 * @param topology FNSS Topology object
 * @return A JUNG graph
 */
public static Graph<String, Edge> getGraph(Topology topology) {
	Graph<String, Edge> graph = null;
	EdgeType edgeType = null;
	if (topology.isDirected()) {
		graph = new DirectedSparseGraph<String, Edge>();
		edgeType = EdgeType.DIRECTED;
	} else {
		graph = new UndirectedSparseGraph<String, Edge>();
		edgeType = EdgeType.UNDIRECTED;
	}
	for(String node : topology.getAllNodes()) {
		graph.addVertex(node);
	}
	for(Pair<String, String> edge : topology.getAllEdges()) {
		graph.addEdge(topology.getEdge(edge), edge.getU(), edge.getV(), edgeType);
	}
	return graph;
}
 
開發者ID:fnss,項目名稱:fnss-java,代碼行數:24,代碼來源:JUNGConverter.java

示例2: addEdge

/**
	 * Overriding addEdge method from SparseGraph to conform
	 * to the
	 */
/*	@Override
	public boolean addEdge(Edge arg0, java.util.Collection<? extends Vertex> arg1, EdgeType arg2) {
		if(directed) {
			return super.addEdge(arg0, arg1, EdgeType.DIRECTED);
		} else {
			return super.addEdge(arg0, arg1, EdgeType.UNDIRECTED);
		}
	};*/
	
	@Override
	public boolean addEdge(Edge e, Vertex v1, Vertex v2, EdgeType edge_type) {
		if(findEdgeSet(v1, v2).size() > 0 && !multiGraph ) {
			System.err.println("The graph does not allow parallel edges");
			return false;
		}
		if(directed)
			return super.addEdge(e, v1, v2, EdgeType.DIRECTED);
		else
			return super.addEdge(e, v1, v2, EdgeType.UNDIRECTED);
	}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:24,代碼來源:CxfNetwork.java

示例3: printEdge

/**
 * private method to print an edge in the file
 * @param edge
 */
private void printEdge(Edge edge)
{

	if (network.getEdgeType(edge) == EdgeType.DIRECTED)
		ps.print("edge: ("+ network.getSource(edge).getId() +","+ network.getDest(edge).getId()+")");
	else
	{
		Pair<Vertex> endpoints = network.getEndpoints(edge);
		ps.print("edge: ("+ endpoints.getFirst().getId() +","+ endpoints.getSecond().getId()+")");	
	}
	if (edge.getLabel() != null)
		ps.print(" label{"+edge.getLabel()+"}");
	ps.print(" weight{"+edge.getWeight()+"}");
	ps.print(" width{"+edge.getWidth()+"}");
	if (edge.getColor() != null)
		ps.print(" color{"+((double)edge.getColor().getRed()/256.d)
				+","+((double)edge.getColor().getGreen()/256.d)+","+((double)edge.getColor().getBlue()/256.d)+"}");
	if (edge.getVar1() != null)
		ps.print(" var1{"+edge.getVar1()+"}");
	if (edge.getVar2() != null)
		ps.print(" var2{"+edge.getVar2()+"}");
	if (edge.isExcluded())
		ps.print(" hide");
	ps.print("\n");
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:29,代碼來源:CxfSaver.java

示例4: getPredecessors

@Override
public Collection<V> getPredecessors(V vertex)
{
    if (!containsVertex(vertex))
        return null;
    
    Set<V> preds = new LinkedHashSet<V>();
    for (E edge : getIncoming_internal(vertex)) {
    	if(getEdgeType(edge) == EdgeType.DIRECTED) {
    		preds.add(this.getSource(edge));
    	} else {
    		preds.add(getOpposite(vertex, edge));
    	}
    }
    return Collections.unmodifiableCollection(preds);
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:16,代碼來源:OrderedSparseMultigraph.java

示例5: removeEdge

public boolean removeEdge(E edge)
{
    if (!containsEdge(edge)) 
        return false;
    
    Pair<V> endpoints = getEndpoints(edge);
    V v1 = endpoints.getFirst();
    V v2 = endpoints.getSecond();
    
    // remove edge from incident vertices' adjacency maps
    if (getEdgeType(edge) == EdgeType.DIRECTED)
    {
        vertex_maps.get(v1)[OUTGOING].remove(v2);
        vertex_maps.get(v2)[INCOMING].remove(v1);
        directed_edges.remove(edge);
    }
    else
    {
        vertex_maps.get(v1)[INCIDENT].remove(v2);
        vertex_maps.get(v2)[INCIDENT].remove(v1);
        undirected_edges.remove(edge);
    }

    return true;
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:25,代碼來源:SparseGraph.java

示例6: toUndirected

/**
 * Transforms <code>graph</code> (which may be of any directionality)
 * into an undirected graph. (This may be useful for
 * visualization tasks).
 * Specifically:
 * <ul>
 * <li/>Vertices are copied from <code>graph</code>.
 * <li/>Directed edges are 'converted' into a single new undirected edge in the new graph.
 * <li/>Each undirected edge (if any) in <code>graph</code> is 'recreated' with a new undirected edge in the new
 * graph if <code>create_new</code> is true, or copied from <code>graph</code> otherwise.
 * </ul>
 * 
 * @param graph     the graph to be transformed
 * @param create_new specifies whether existing undirected edges are to be copied or recreated
 * @param graph_factory used to create the new graph object
 * @param edge_factory used to create new edges
 * @return          the transformed <code>Graph</code>
 */
public static <V,E> UndirectedGraph<V,E> toUndirected(Graph<V,E> graph, 
		Factory<UndirectedGraph<V,E>> graph_factory,
        Factory<E> edge_factory, boolean create_new)
{
    UndirectedGraph<V,E> out = graph_factory.create();
    
    for (V v : graph.getVertices())
        out.addVertex(v);
    
    for (E e : graph.getEdges())
    {
        Pair<V> endpoints = graph.getEndpoints(e);
        V v1 = endpoints.getFirst();
        V v2 = endpoints.getSecond();
        E to_add;
        if (graph.getEdgeType(e) == EdgeType.DIRECTED || create_new)
            to_add = edge_factory.create();
        else
            to_add = e;
        out.addEdge(to_add, v1, v2, EdgeType.UNDIRECTED);
    }
    return out;
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:41,代碼來源:DirectionTransformer.java

示例7: GraphEdgeConnection

/**
 * Instantiates a new graph edge connection.
 */
public GraphEdgeConnection(NetworkModel networkModel, NetworkComponent networkComponent, GraphEdge graphEdge) {

	this.graphEdge = graphEdge;
	
	EdgeType edgeType = networkModel.getGraph().getEdgeType(this.graphEdge);
	
	if (networkComponent.isDirected() && edgeType==EdgeType.DIRECTED) {
		this.fixedDirected = true;	
		this.graphNode1 = networkModel.getGraph().getSource(this.graphEdge);
		this.graphNode2 = networkModel.getGraph().getDest(this.graphEdge);
		
	} else {
		this.fixedDirected = false;
		Pair<GraphNode> nodePair = networkModel.getGraph().getEndpoints(this.graphEdge);
		this.graphNode1 = nodePair.getFirst();
		this.graphNode2 = nodePair.getSecond();
	}
	
	HashSet<NetworkComponent> netComps = null; 
	
	netComps = networkModel.getNetworkComponents(this.graphNode1);
	netComps.remove(networkComponent);
	if (netComps.size()>0) {
		this.externalNetworkComponent1 = netComps.iterator().next();	
	}
	
	netComps = networkModel.getNetworkComponents(this.graphNode2);
	netComps.remove(networkComponent);
	if (netComps.size()>0) {
		this.externalNetworkComponent2 = netComps.iterator().next();	
	}
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:35,代碼來源:GraphEdgeConnection.java

示例8: toString

public String toString(E e, boolean verbose) {
    String edge_marker = null;
    V source = null;
    V dest = null;
    
    // Directed
    if (this.graph.getEdgeType(e) == EdgeType.DIRECTED) {
        edge_marker = "->";
        source = this.graph.getSource(e);
        dest = this.graph.getDest(e);
    // Undirected
    } else {
        edge_marker = "--";
        for (V v : this.graph.getIncidentVertices(e)) {
            if (source == null) source = v;
            else if (dest == null) dest = v;
            else assert(false);
        } // FOR
    }
    assert(source != null);
    assert(dest != null);
    
    String source_lbl = source.toString();
    String dest_lbl = dest.toString();

    // If the edge doesn't have verbose output enabled, truncate the vertex labels
    if (verbose == false) {
        source_lbl = source_lbl.substring(0, 2);
        dest_lbl = dest_lbl.substring(0, 2);
    }
    return (source_lbl + edge_marker + dest_lbl);
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:32,代碼來源:InnerGraphInformation.java

示例9: mousePressed

/**
    * If the mouse is pressed in an empty area, create a new vertex there.
    * If the mouse is pressed on an existing vertex, prepare to create
    * an edge from that vertex to another
    */
@SuppressWarnings("unchecked")
@Override
public void mousePressed(MouseEvent e) {
	if (checkModifiers(e)) {
		final VisualizationViewer<Vertex, Edge> vv = (VisualizationViewer<Vertex, Edge>) e.getSource();
		final Point2D p = e.getPoint();
		GraphElementAccessor<Vertex, Edge> pickSupport = vv.getPickSupport();

		if (pickSupport != null) {
			final Vertex vertex = pickSupport.getVertex(vv.getModel().getGraphLayout(), p.getX(), p.getY());

			if (vertex != null) { // get ready to make an edge
				creatingAnEdge = true;
				Graph<Vertex, Edge> graph = vv.getModel().getGraphLayout().getGraph();
				edgeType = (graph instanceof DirectedGraph) ? EdgeType.DIRECTED : EdgeType.UNDIRECTED;
				if ((e.getModifiers() & MouseEvent.SHIFT_MASK) != 0 && graph instanceof UndirectedGraph == false) {
					edgeType = EdgeType.DIRECTED;
				}

				super.mousePressed(e);

			} else { // make a new vertex
				creatingAnEdge = false;
				Vertex newVertex = (Vertex) vertexFactory.create();
				action = new CreateVertexUndoableAction(vv.getGraphLayout(), newVertex, vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p));
				action.execute();
				UndoableControl.getController().actionExecuted(action);
			}
		}
	}

}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:37,代碼來源:UndoableEditingGraphMousePlugin.java

示例10: addEdge

/**
 * Below several method override the methods
 * from BrowsableNetwork so that the directivity of the
 * network matches with the direction parameter
 * in this network
 */
@Override
public boolean addEdge(Edge arg0, java.util.Collection<? extends Vertex> arg1, EdgeType arg2) {
	if(directed)
		return super.addEdge(arg0, arg1, EdgeType.DIRECTED);
	else
		return super.addEdge(arg0, arg1, EdgeType.UNDIRECTED);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:13,代碼來源:JsonNetwork.java

示例11: evaluate

public boolean evaluate(Context<Graph<V,E>,E> context)
{
	Graph<V,E> graph = context.graph;
	E e = context.element;
    if (graph.getEdgeType(e) == EdgeType.DIRECTED && show_d) {
        return true;
    }
    if (graph.getEdgeType(e) == EdgeType.UNDIRECTED && show_u) {
        return true;
    }
    return false;
}
 
開發者ID:marcvanzee,項目名稱:mdp-plan-revision,代碼行數:12,代碼來源:PluggableRendererDemo.java

示例12: evaluate

@Override
public boolean evaluate(Context<Graph<V, E>, E> context) {
    Graph<V, E> graph = context.graph;
    E edge = context.element;
    if (graph.getEdgeType(edge) == EdgeType.DIRECTED) {
        return true;
    }
    if (graph.getEdgeType(edge) == EdgeType.UNDIRECTED) {
        return true;
    }
    return true;
}
 
開發者ID:datapoet,項目名稱:hubminer,代碼行數:12,代碼來源:ImageHubExplorer.java

示例13: edgeType

/**
 * Converts a String into an <code>EdgeType</code>.
 * @param s contains an edge type.
 * @return The converted <code>EdgeType</code>
 * @throws InvalidDataValueException if s is not "directed" or "undirected".
 */
public static EdgeType edgeType(String s) throws InvalidDataValueException {
    if (s.equalsIgnoreCase("DIRECTED"))
        return EdgeType.DIRECTED;
    else if (s.equalsIgnoreCase("UNDIRECTED"))
        return EdgeType.UNDIRECTED;
    else
        throw new InvalidDataValueException("Edge type must be directed or undirected. Value \""+s+"\" is not allowed.");
}
 
開發者ID:ave4224,項目名稱:gexf2jung,代碼行數:14,代碼來源:Edge.java

示例14: assignEdgeSourceTarget

protected void assignEdgeSourceTarget(E e, Attributes atts,
		Map<String, String> edge_atts)//, String id)
	throws SAXNotSupportedException
{
    String source_id = edge_atts.remove("source");
    if (source_id == null)
        throw new SAXNotSupportedException("edge attribute list missing " +
        		"'source': " + atts.toString());
    V source = vertex_ids.getKey(source_id);
    if (source == null)
        throw new SAXNotSupportedException("specified 'source' attribute " +
        		"\"" + source_id + "\" does not match any node ID");

    String target_id = edge_atts.remove("target");
    if (target_id == null)
        throw new SAXNotSupportedException("edge attribute list missing " +
        		"'target': " + atts.toString());
    V target = vertex_ids.getKey(target_id);
    if (target == null)
        throw new SAXNotSupportedException("specified 'target' attribute " +
        		"\"" + target_id + "\" does not match any node ID");

    String directed = edge_atts.remove("directed");
    EdgeType edge_type;
    if (directed == null)
        edge_type = default_edgetype;
    else if (directed.equals("true"))
        edge_type = EdgeType.DIRECTED;
    else if (directed.equals("false"))
        edge_type = EdgeType.UNDIRECTED;
    else
        throw new SAXNotSupportedException("Unrecognized edge direction specifier 'direction=\"" +
        		directed + "\"': " + "source: " + source_id + ", target: " + target_id);

    if (current_graph instanceof Graph)
        ((Graph<V,E>)this.current_graph).addEdge(e, source, target,
        		edge_type);
    else
        this.current_graph.addEdge(e, new Pair<V>(source, target));
}
 
開發者ID:iTransformers,項目名稱:netTransformer,代碼行數:40,代碼來源:MyGraphMLReader.java

示例15: OrderedKAryTree

/**
 * Creates a new instance with the specified order (maximum number of children).
 */
public OrderedKAryTree(int order)
{
	super(EdgeType.DIRECTED);
	this.order = order;
	this.height = -1;
	this.edge_vpairs = new HashMap<E, Pair<V>>();
	this.vertex_data = new HashMap<V, VertexData>();
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:11,代碼來源:OrderedKAryTree.java


注:本文中的edu.uci.ics.jung.graph.util.EdgeType.DIRECTED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。