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


Java Node类代码示例

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


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

示例1: create

import org.gephi.graph.api.Node; //导入依赖的package包/类
public HierarchicalDirectedGraph create() {

		// Minimum Spanning Tree identifier
		MST_ID++;

		Node root = null;
		if (roots != null && !roots.isEmpty()) {
			root = roots.iterator().next();
			roots.remove(root);
			System.out.println("MST Root Vertex: " + root);

		} else {
			throw new RuntimeException("No root(s) specified for the MST!");
		}

		for (Node n : tree.getNodes())
			reset(n);

		for (org.gephi.graph.api.Edge e : tree.getEdges())
			reset(e);

		mark(root);
		updateTree();

		return tree;
	}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:27,代码来源:MinimumSpanningTree.java

示例2: createTree

import org.gephi.graph.api.Node; //导入依赖的package包/类
private void createTree(Collection<Node> roots) {
	MinimumSpanningTree mst = new MinimumSpanningTree(this.forest, roots);
	this.forest = mst.create();

	// Filter only the edges that belong to the spanning tree
	AbstractAttributeFilter edgeFilter = mst.getEdgeFilter();
	edgeFilter.init(forest);

	FilterController filterController = Lookup.getDefault().lookup(
			FilterController.class);

	Query query = filterController.createQuery(edgeFilter);
	GraphView view = filterController.filter(query);

	graphModel.setVisibleView(view);
	forest = graphModel.getHierarchicalDirectedGraphVisible();
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:18,代码来源:BrowsableForestNetwork.java

示例3: getRoots

import org.gephi.graph.api.Node; //导入依赖的package包/类
/**
 * This is a private method that checks all vertices and extracts the root
 * vertices into a collection.
 * 
 * @return A collection with the root nodes of the Forest
 */
private static Collection<Node> getRoots(Graph graph) {
	Collection<Node> roots = new ArrayList<Node>();

	for (Node n : graph.getNodes().toArray()) {
		boolean isRoot = true;
		for (org.gephi.graph.api.Edge e : graph.getEdges(n).toArray()) {
			if (e.getTarget().equals(n)) {
				isRoot = false;
				break;
			}
		}

		if (isRoot)
			roots.add(n);
	}
	return roots;
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:24,代码来源:BrowsableForestNetwork.java

示例4: initAlgo

import org.gephi.graph.api.Node; //导入依赖的package包/类
@Override
public void initAlgo() {
	if (graphModel == null) {
		throw new RuntimeException(
				"The GraphModel for this layout cannot be null!");
	}

	graph = graphModel.getGraphVisible();

	circleNodeDataMap = LazyMap.decorate(
			new HashMap<Node, CircleNodeData>(),
			new Factory<CircleNodeData>() {
				public CircleNodeData create() {
					return new CircleNodeData();
				}
			});

	nodeOrderedList = new ArrayList<Node>();
	for (Node n : graph.getNodes())
		nodeOrderedList.add(n);

	if (LayoutLoader.VERBOSE_LAYOUT)
		Cuttlefish.debug(this, "Layout initialized.");
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:25,代码来源:CircleLayout.java

示例5: computeCore

import org.gephi.graph.api.Node; //导入依赖的package包/类
private void computeCore(Map<Node, Integer> degree, int core) {
	Color c = new Color(new Random().nextInt());
	List<Node> shell = new ArrayList<Node>();

	for (Node n : degree.keySet()) {
		if (degree.get(n) <= core) {
			coreness.put(n, core);
			shell.add(n);
			new Vertex(n).setFillColor(c);
		}
	}

	for (Node v : shell) {
		degree.remove(v);
		for (Edge e : graph.getEdges(v)) {
			Node adjacentV = graph.getOpposite(v, e);

			if (degree.containsKey(adjacentV)) {
				int newDegree = degree.get(adjacentV) - 1;
				degree.remove(adjacentV);
				degree.put(adjacentV, newDegree);
			}
		}
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:26,代码来源:KCoreLayout.java

示例6: computeRho

import org.gephi.graph.api.Node; //导入依赖的package包/类
private void computeRho(Graph g, int cmax) {
	for (Node n1 : g.getNodes()) {
		int sum = 0;
		List<Node> neighbors = getNeighborsWithHigherCoreness(g, n1);

		for (Node n2 : neighbors) {
			sum += cmax - coreness.get(n2);
		}

		double r = (1 - EPSILON) * (cmax - coreness.get(n1))
				+ (EPSILON / neighbors.size()) * sum;

		if (r > 0 && cmaxRadius > r)
			cmaxRadius = r;

		rho.put(n1, r);
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:19,代码来源:KCoreLayout.java

示例7: computeGraphCoreness

import org.gephi.graph.api.Node; //导入依赖的package包/类
private void computeGraphCoreness() {
	Map<Node, Integer> degree = new HashMap<Node, Integer>();
	Map<Node, Integer> weightedDegree = new HashMap<Node, Integer>();
	coreIndex = 0;

	for (Node v : graph.getNodes()) {
		degree.put(v, graph.getDegree(v));
	}

	normalizeWeights(graph.getEdges());
	computeWeightedDegree(degree, weightedDegree, paramAlpha, paramBeta);

	int minWeight;
	while (!weightedDegree.isEmpty()) {
		// Get a vertex of minimum degree

		minWeight = Collections.min(weightedDegree.values());
		computeCore(weightedDegree, degree, minWeight);
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:21,代码来源:WeightedKCoreLayout.java

示例8: computeWeightedDegree

import org.gephi.graph.api.Node; //导入依赖的package包/类
private void computeWeightedDegree(final Map<Node, Integer> degree,
		Map<Node, Integer> weightedDegree, final double alpha,
		final double beta) {

	double weightSum;
	double w;

	weightedDegree.clear();
	for (Node v : degree.keySet()) {
		weightSum = 0;

		for (Edge e : graph.getEdges(v)) {
			Node opposite = graph.getOpposite(v, e);
			if (degree.containsKey(opposite)) {
				weightSum += normalizedWeight.get(e);
			}
		}

		w = Math.pow(degree.get(v), alpha) * Math.pow(weightSum, beta);
		w = Math.pow(w, 1 / (alpha + beta));
		weightedDegree.put(v, (int) Math.round(w));
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:24,代码来源:WeightedKCoreLayout.java

示例9: computeRho

import org.gephi.graph.api.Node; //导入依赖的package包/类
private void computeRho(Graph g, int cmax) {
	for (Node v : g.getNodes()) {
		int sum = 0;

		List<Node> neighbors = getNeighborsWithHigherCoreness(g, v);

		for (Node n : neighbors) {
			sum += cmax - coreness.get(n);
		}
		double r = (1 - EPSILON) * (cmax - coreness.get(v))
				+ (EPSILON / neighbors.size()) * sum;
		if (r > 0 && cmaxRadius > r)
			cmaxRadius = r;
		rho.put(v, r);
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:17,代码来源:WeightedKCoreLayout.java

示例10: advancePositions

import org.gephi.graph.api.Node; //导入依赖的package包/类
private void advancePositions() {
	double change = 0;
	int nodeCount = graph.getNodeCount();

	for (int iter = 0; iter < updatesPerFrame; ++iter) {
		for (Node n : graph.getNodes()) {

			Point2D.Float f = getForceforNode(n);
			double log = Math.log10(nodeCount) == 0 ? 1 : Math
					.log10(nodeCount);
			double delta = graph.getDegree(n) > 1 ? (deltaT / log)
					/ Math.pow(graph.getDegree(n), 0.4) : (deltaT / log);

			f.setLocation(f.getX() * delta, f.getY() * delta);

			n.getNodeData().setX(
					n.getNodeData().x() + (float) f.getX() / sensitivity);
			n.getNodeData().setY(
					n.getNodeData().y() + (float) f.getY() / sensitivity);

			change += Math.abs(f.getX()) + Math.abs(f.getY());
		}
	}
	setChange(change);
	align(100, 100);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:27,代码来源:WeightedARFLayout.java

示例11: advancePositions

import org.gephi.graph.api.Node; //导入依赖的package包/类
private void advancePositions() {
	double c = 0;
	int nodeCount = graph.getNodeCount();

	for (int iter = 0; iter < updatesPerFrame; ++iter) {
		for (Node n : graph.getNodes()) {
			Point2D.Float f = getForceforNode(n);
			double log = Math.log10(nodeCount) == 0 ? 1 : Math
					.log10(nodeCount);
			double delta = graph.getDegree(n) > 1 ? (deltaT / log)
					/ Math.pow(graph.getDegree(n), 0.4) : (deltaT / log);

			f.setLocation(f.getX() * delta, f.getY() * delta);

			n.getNodeData().setX(
					n.getNodeData().x() + (float) (f.getX() / sensitivity));
			n.getNodeData().setY(
					n.getNodeData().y() + (float) (f.getY() / sensitivity));

			c += Math.abs(f.getX()) + Math.abs(f.getY());
		}
	}

	setChange(c);
	align(100, 100);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:27,代码来源:ARFLayout.java

示例12: calculateAngle

import org.gephi.graph.api.Node; //导入依赖的package包/类
private double calculateAngle(Node n) {
    if (center == null) {
        // center = Utils.caculateCenter(layout, network);
        center = new Point2D.Float(0,0);
    }
    if (n.getNodeData().x() > center.getX()) {
        if (n.getNodeData().y() < center.getY())
            return 45;
        else
            return 315;
    } else {
        if (n.getNodeData().y() < center.getY())
            return 135;
        else
            return 225;
    }
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:18,代码来源:TikzExport.java

示例13: apply

import org.gephi.graph.api.Node; //导入依赖的package包/类
@Override
public void apply(Node n1, Node n2) {
    NodeData n1Data = n1.getNodeData();
    ForceAtlas2LayoutData n1Layout = n1Data.getLayoutData();
    NodeData n2Data = n2.getNodeData();
    ForceAtlas2LayoutData n2Layout = n2Data.getLayoutData();

    // Get the distance
    double xDist = n1Data.x() - n2Data.x();
    double yDist = n1Data.y() - n2Data.y();
    double distance = (float) Math.sqrt(xDist * xDist + yDist * yDist);

    if (distance > 0) {
        // NB: factor = force / distance
        double factor = coefficient * n1Layout.mass * n2Layout.mass / distance / distance;

        n1Layout.dx += xDist * factor;
        n1Layout.dy += yDist * factor;

        n2Layout.dx -= xDist * factor;
        n2Layout.dy -= yDist * factor;
    }
}
 
开发者ID:nolanlab,项目名称:vortex,代码行数:24,代码来源:ForceFactory.java

示例14: applyForce

import org.gephi.graph.api.Node; //导入依赖的package包/类
public void applyForce(Node n, RepulsionForce Force, double theta) {
    NodeData nData = n.getNodeData();
    if (nodes.size() < 2) {
        Node regionNode = nodes.get(0);
        Force.apply(n, regionNode);
    } else {
        double distance = Math.sqrt((nData.x() - massCenterX) * (nData.x() - massCenterX) + (nData.y() - massCenterY) * (nData.y() - massCenterY));
        if (distance * theta > size) {
            Force.apply(n, this);
        } else {
            for (Region subregion : subregions) {
                subregion.applyForce(n, Force, theta);
            }
        }
    }
}
 
开发者ID:nolanlab,项目名称:vortex,代码行数:17,代码来源:Region.java

示例15: getSwitchedDistanceSum

import org.gephi.graph.api.Node; //导入依赖的package包/类
private double getSwitchedDistanceSum(Node node, int newSlot) {
    if (node == null) {
        return 0;
    }
    double sum = 0;

    DagLayoutData layoutData = getLayoutData(node);
    int x = newSlot;
    int y = layoutData.getLayer();

    DirectedGraph diGraph = graphModel.getDirectedGraph();
    EdgeIterable edges = diGraph.getEdges(node);
    for (Edge edge : edges) {
        Node otherNode = diGraph.getOpposite(node, edge);
        DagLayoutData otherLayoutData = getLayoutData(otherNode);
        int otherX = otherLayoutData.getSlot();
        int otherY = otherLayoutData.getLayer();
        int dx = x - otherX;
        int dy = y - otherY;

        double dist = Math.sqrt(dx * dx + dy * dy);
        sum += dist;
    }
    return sum;

}
 
开发者ID:nolanlab,项目名称:vortex,代码行数:27,代码来源:TreeLayout.java


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