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


Java Hypergraph类代码示例

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


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

示例1: initialize

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
protected void initialize(Hypergraph<V,E> g, Set<V> rootSet) {
    mVerticesInOrderVisited = new ArrayList<V>();
    mUnvisitedVertices = new HashSet<V>();
    for(V currentVertex : g.getVertices()) {
        mUnvisitedVertices.add(currentVertex);
        mPredecessorMap.put(currentVertex,new HashSet<V>());
    }

    mCurrentList = new ArrayList<V>();
    for(V v : rootSet) {
        distanceDecorator.put(v, new Integer(0));
        mCurrentList.add(v);
        mUnvisitedVertices.remove(v);
        mVerticesInOrderVisited.add(v);
    }
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:17,代码来源:BFSDistanceLabeler.java

示例2: labelDistances

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Computes the distances of all the node from the starting root nodes. If there is more than one root node
 * the minimum distance from each root node is used as the designated distance to a given node. Also keeps track
 * of the predecessors of each node traversed as well as the order of nodes traversed.
 * @param graph the graph to label
 * @param rootSet the set of starting vertices to traverse from
 */
public void labelDistances(Hypergraph<V,E> graph, Set<V> rootSet) {

    initialize(graph,rootSet);

    int distance = 1;
    while (true) {
        List<V> newList = new ArrayList<V>();
        for(V currentVertex : mCurrentList) {
        	if(graph.containsVertex(currentVertex)) {
        		for(V next : graph.getSuccessors(currentVertex)) {
        			visitNewVertex(currentVertex,next, distance, newList);
        		}
        	}
        }
        if (newList.size() == 0) break;
        mCurrentList = newList;
        distance++;
    }

    for(V v : mUnvisitedVertices) {
        distanceDecorator.put(v,new Integer(-1));
    }
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:31,代码来源:BFSDistanceLabeler.java

示例3: writeVertexData

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
protected void writeVertexData(Hypergraph<V,E> graph, BufferedWriter w) throws IOException
{
	for (V v: graph.getVertices())
	{
		String v_string = String.format("<node id=\"%s\"", vertex_ids.transform(v));
		boolean closed = false;
		// write description out if any
		String desc = vertex_desc.transform(v);
		if (desc != null)
		{
			w.write(v_string + ">\n");
			closed = true;
			w.write("<desc>" + desc + "</desc>\n");
		}
		// write data out if any
		for (String key : vertex_data.keySet())
		{
			Transformer<V, ?> t = vertex_data.get(key).transformer;
			if (t != null)
			{
   				Object value = t.transform(v);
   				if (value != null)
   				{
   					if (!closed)
   					{
   						w.write(v_string + ">\n");
   						closed = true;
   					}
   					w.write(format("data", "key", key, StringEscapeUtils.escapeXml(value.toString())) + "\n");
   				}
			}
		}
		if (!closed)
			w.write(v_string + "/>\n"); // no contents; close the node with "/>"
		else
		    w.write("</node>\n");
	}
}
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:39,代码来源:MyGraphMLWriter.java

示例4: addGraphData

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Adds a new graph data specification.
 */
public void addGraphData(String id, String description, String default_value,
		Transformer<Hypergraph<V,E>, String> graph_transformer)
{
	if (graph_data.equals(Collections.EMPTY_MAP))
		graph_data = new HashMap<String, GraphMLMetadata<Hypergraph<V,E>>>();
	graph_data.put(id, new GraphMLMetadata<Hypergraph<V,E>>(description, 
			default_value, graph_transformer));
}
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:12,代码来源:MyGraphMLWriter.java

示例5: getDistance

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Given a vertex, returns the shortest distance from any node in the root set to v
 * @param v the vertex whose distance is to be retrieved
 * @return the shortest distance from any node in the root set to v
 */
public int getDistance(Hypergraph<V,E> g, V v) {
    if (!g.getVertices().contains(v)) {
        throw new IllegalArgumentException("Vertex is not contained in the graph.");
    }

    return distanceDecorator.get(v).intValue();
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:13,代码来源:BFSDistanceLabeler.java

示例6: UnweightedShortestPath

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Constructs and initializes algorithm
 * @param g the graph
 */
public UnweightedShortestPath(Hypergraph<V,E> g)
{
	mDistanceMap = new HashMap<V,Map<V,Number>>();
	mIncomingEdgeMap = new HashMap<V,Map<V,E>>();
	mGraph = g;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:11,代码来源:UnweightedShortestPath.java

示例7: AbstractIterativeScorer

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Creates an instance for the specified graph and edge weights.
 * @param g the graph for which the instance is to be created
 * @param edge_weights the edge weights for this instance
 */
public AbstractIterativeScorer(Hypergraph<V,E> g, Transformer<E, ? extends Number> edge_weights)
{
    this.graph = g;
    this.max_iterations = 100;
    this.tolerance = 0.001;
    this.accept_disconnected_graph = true;
    setEdgeWeights(edge_weights);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:14,代码来源:AbstractIterativeScorer.java

示例8: HITSWithPriors

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Creates an instance for the specified graph, vertex priors, and random
 * jump probability (alpha).  The edge weights default to 1.0.
 * @param g the input graph
 * @param vertex_priors the prior probability for each vertex
 * @param alpha the probability of a random jump at each step
 */
@SuppressWarnings("unchecked")
public HITSWithPriors(Hypergraph<V,E> g, 
      Transformer<V, HITS.Scores> vertex_priors, double alpha)
{
	super(g, new ConstantTransformer(1.0), vertex_priors, alpha);
    disappearing_potential = new HITS.Scores(0,0);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:15,代码来源:HITSWithPriors.java

示例9: VoltageScorer

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Creates an instance with the specified graph, edge weights, source voltages,
 * and sinks.
 * @param g the input graph
 * @param edge_weights the edge weights, representing conductivity
 * @param source_voltages the (fixed) voltage for each source
 * @param sinks the vertices whose voltages are tied to 0
 */
public VoltageScorer(Hypergraph<V, E> g, Transformer<E, ? extends Number> edge_weights, 
        Map<V, ? extends Number> source_voltages, Collection<V> sinks)
{
    super(g, edge_weights);
    this.source_voltages = source_voltages;
    this.sinks = sinks;
    initialize();
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:17,代码来源:VoltageScorer.java

示例10: AbstractIterativeScorerWithPriors

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Creates an instance for the specified graph, edge weights, vertex
 * priors, and jump probability.
 * @param g the graph whose vertices are to be assigned scores
 * @param edge_weights the edge weights to use in the score assignment
 * @param vertex_priors the prior probabilities of each vertex being 'jumped' to
 * @param alpha the probability of making a 'jump' at each step
 */
public AbstractIterativeScorerWithPriors(Hypergraph<V,E> g,
        Transformer<E,? extends Number> edge_weights, 
        Transformer<V,? extends S> vertex_priors, double alpha)
{
    super(g, edge_weights);
    this.vertex_priors = vertex_priors;
    this.alpha = alpha;
    initialize();
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:18,代码来源:AbstractIterativeScorerWithPriors.java

示例11: writeVertexData

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
protected void writeVertexData(Hypergraph<V,E> graph, BufferedWriter w) throws IOException
{
	for (V v: graph.getVertices())
	{
		String v_string = String.format("<node id=\"%s\"", vertex_ids.transform(v));
		boolean closed = false;
		// write description out if any
		String desc = vertex_desc.transform(v);
		if (desc != null)
		{
			w.write(v_string + ">\n");
			closed = true;
			w.write("<desc>" + desc + "</desc>\n");
		}
		// write data out if any
		for (String key : vertex_data.keySet())
		{
			Transformer<V, ?> t = vertex_data.get(key).transformer;
			if (t != null)
			{
   				Object value = t.transform(v);
   				if (value != null)
   				{
   					if (!closed)
   					{
   						w.write(v_string + ">\n");
   						closed = true;
   					}
   					w.write(format("data", "key", key, value.toString()) + "\n");
   				}
			}
		}
		if (!closed)
			w.write(v_string + "/>\n"); // no contents; close the node with "/>"
		else
		    w.write("</node>\n");
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:39,代码来源:GraphMLWriter.java

示例12: copy

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * @see edu.uci.ics.jung.graph.ArchetypeVertex#copy(edu.uci.ics.jung.graph.ArchetypeGraph)
 */
public ArchetypeVertex copy(ArchetypeGraph g)
{
    AbstractHypervertex v = (AbstractHypervertex)super.copy(g);
    ((Hypergraph)g).addVertex(v);
    return v;
}
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:10,代码来源:AbstractHypervertex.java

示例13: copy

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Creates a copy of this edge in the specified graph <code>newGraph</code>,
 * and copies this edge's user data to the new edge.  Connects this 
 *
 * @see edu.uci.ics.jung.graph.ArchetypeEdge#copy(edu.uci.ics.jung.graph.ArchetypeGraph)
 */
public ArchetypeEdge copy(ArchetypeGraph newGraph)
{
    Hyperedge e = (Hyperedge)super.copy(newGraph);
    ((Hypergraph)newGraph).addEdge(e);
    
    for (Iterator iter = getVertices_internal().iterator(); iter.hasNext(); )
    {
        Hypervertex v = (Hypervertex)iter.next();
        e.connectVertex((Hypervertex)v.getEqualVertex(newGraph));
    }
    return e;
}
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:19,代码来源:AbstractHyperedge.java

示例14: writeEdgeData

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
protected void writeEdgeData(Hypergraph<V,E> g, Writer w) throws IOException
{
	for (E e: g.getEdges())
	{
		Collection<V> vertices = g.getIncidentVertices(e);
		String id = edge_ids.transform(e);
		String e_string;
		boolean is_hyperedge = !(g instanceof Graph);
           if (is_hyperedge)
           {
               e_string = "<hyperedge ";
               // add ID if present
               if (id != null)
                   e_string += "id=\"" + id + "\" ";
           }
           else
		{
			Pair<V> endpoints = new Pair<V>(vertices);
			V v1 = endpoints.getFirst();
			V v2 = endpoints.getSecond();
			e_string = "<edge ";
			// add ID if present
			if (id != null)
				e_string += "id=\"" + id + "\" ";
			// add edge type if doesn't match default
			EdgeType edge_type = g.getEdgeType(e);
			if (directed && edge_type == EdgeType.UNDIRECTED)
				e_string += "directed=\"false\" ";
			if (!directed && edge_type == EdgeType.DIRECTED)
				e_string += "directed=\"true\" ";
			e_string += "source=\"" + vertex_ids.transform(v1) + 
				"\" target=\"" + vertex_ids.transform(v2) + "\"";
		}
		
		boolean closed = false;
		// write description out if any
		String desc = edge_desc.transform(e);
		if (desc != null)
		{
			w.write(e_string + ">\n");
			closed = true;
			w.write("<desc>" + desc + "</desc>\n");
		}
		// write data out if any
		for (String key : edge_data.keySet())
		{
			Transformer<E, ?> t = edge_data.get(key).transformer;
			Object value = t.transform(e);
			if (value != null)
			{
				if (!closed)
				{
					w.write(e_string + ">\n");
					closed = true;
				}
				w.write(format("data", "key", key, StringEscapeUtils.escapeXml(value.toString())) + "\n");
			}
		}
		// if this is a hyperedge, write endpoints out if any
		if (is_hyperedge)
		{
			for (V v : vertices)
			{
				if (!closed)
				{
					w.write(e_string + ">\n");
					closed = true;
				}
				w.write("<endpoint node=\"" + vertex_ids.transform(v) + "\"/>\n");
			}
		}
		
		if (!closed)
			w.write(e_string + "/>\n"); // no contents; close the edge with "/>"
		else
		    if (is_hyperedge)
		        w.write("</hyperedge>\n");
		    else
		        w.write("</edge>\n");
	}
}
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:82,代码来源:MyGraphMLWriter.java

示例15: setGraphData

import edu.uci.ics.jung.graph.Hypergraph; //导入依赖的package包/类
/**
 * Provides a map from data type name to graph data.
 */
public void setGraphData(Map<String, GraphMLMetadata<Hypergraph<V,E>>> graph_map)
{
	graph_data = graph_map;
}
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:8,代码来源:MyGraphMLWriter.java


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