本文整理汇总了Java中org.graphstream.graph.Edge.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Edge.addAttribute方法的具体用法?Java Edge.addAttribute怎么用?Java Edge.addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.graphstream.graph.Edge
的用法示例。
在下文中一共展示了Edge.addAttribute方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDependence
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
public synchronized void showDependence(String from, double fX, double fY,
String to, double tX, double tY,
double weight) {
showNode(from, fX, fY);
showNode(to, tX, tY);
int id = uniqId++;
try {
Node fromNode = graph.getNode(from);
if(fromNode == null || !fromNode.hasEdgeToward(to)) {
Edge edge = graph.addEdge(String.valueOf(id), from, to, true);
edge.addAttribute("ui.hide");
final String style =
String.format("fill-color: rgba(150,150,150,50);size: %spx;",
Double.isNaN(weight) ? 5 : plateau(weight));
edge.addAttribute("ui.style", style);
}
} catch (IdAlreadyInUseException e) { }
}
示例2: addViewTransition
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
public void addViewTransition(Command command, io.supermonkey.crawler.device.View oldView, io.supermonkey.crawler.device.View newView) {
org.graphstream.graph.Node oldNode = getOrCreateNode(oldView);
org.graphstream.graph.Node newNode = getOrCreateNode(newView);
oldNode.setAttribute("ui.label", oldView.getId().getShortName());
newNode.setAttribute("ui.label", newView.getId().getShortName());
for(Node node : graph.getEachNode()) {
node.removeAttribute("ui.class");
}
newNode.addAttribute("ui.class", "current");
String edgeLabel = toString(command);
Edge edge = getOrCreateEdge(toEdgeId(edgeLabel, oldNode, newNode), oldNode, newNode);
if(edge.isLoop()) {
edge.addAttribute("ui.class", "loop");
}
//edge.setAttribute("ui.label", edgeLabel);
}
示例3: createControlFlowGraphEdge
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
/**
* Creates an edge between two CFG nodes.
*
* @param src
* @param dest
* @author Shashank B S
*/
private void createControlFlowGraphEdge(VFNode src, VFNode dest) {
if (graph.getEdge("" + src.getId() + dest.getId()) == null) {
Edge createdEdge = graph.addEdge(src.getId() + "" + dest.getId(), src.getId() + "", dest.getId() + "", true);
VFUnit unit = src.getVFUnit();
createdEdge.addAttribute("ui.label", Optional.fromNullable(unit.getOutSet()).or("").toString());
createdEdge.addAttribute("edgeData.outSet", Optional.fromNullable(unit.getInSet()).or("").toString());
}
}
示例4: addEdge
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
private Edge addEdge(Node from, Node to, int id) {
try {
if(!checkNotNull(from).hasEdgeToward(checkNotNull(to))) {
Edge graphicEdge = graphicGraph.addEdge(String.valueOf(id), from, to, true);
graphicEdge.addAttribute("ui.hide");
return graphicEdge;
}
} catch (IdAlreadyInUseException e) { }
return graphicGraph.getEdge(String.valueOf(id));
}
示例5: weighEdges
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
private void weighEdges() {
double maxCount = flowGraph.maxEdgeCount() + 1.0;
for(Edge edge : graphicGraph.getEachEdge()) {
Node from = edge.getSourceNode();
Node to = edge.getTargetNode();
int fromId = Integer.parseInt(from.toString());
int toId = Integer.parseInt(to.toString());
int count = flowGraph.getEdgeCount(fromId, toId);
double weight = (maxCount - count)/maxCount;
edge.addAttribute("layout.weight", weight);
}
}
示例6: weighEdges
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
public void weighEdges() {
double maxCount = displayedGraph.maxEdgeCount() + 1.0;
for(Edge edge : graph.getEachEdge()) {
Node from = edge.getSourceNode();
Node to = edge.getTargetNode();
int fromId = Integer.parseInt(from.toString());
int toId = Integer.parseInt(to.toString());
int count = displayedGraph.getEdgeCount(fromId, toId);
double weight = (maxCount - count)/maxCount;
edge.addAttribute("layout.weight", weight);
}
}
示例7: mergeGraphs
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
@Override
public VPMGraph mergeGraphs(List<VPMGraph> graphs) {
if (graphs.size() == 0) {
return null;
}
VPMGraph graph = graphs.get(0);
for (VPMGraph currentGraph : graphs) {
if (currentGraph == graph) {
continue;
}
for (Edge edge : currentGraph.getEachEdge()) {
String edgeId = edge.getId();
String sourceNodeId = edge.getSourceNode().getId();
String targetNodeId = edge.getTargetNode().getId();
Node sourceNode = graph.getNode(sourceNodeId);
Edge mergeEdge = sourceNode.getEdgeBetween(targetNodeId);
if (mergeEdge == null) {
mergeEdge = graph.addEdge(edgeId, sourceNodeId, targetNodeId);
for (String key : edge.getAttributeKeySet()) {
mergeEdge.addAttribute(key, edge.getAttribute(key));
}
} else {
RelationshipEdge relEdge = (RelationshipEdge) edge;
RelationshipEdge relMergeEdge = (RelationshipEdge) mergeEdge;
relMergeEdge.getRelationshipInfos().addAll(relEdge.getRelationshipInfos());
relMergeEdge.getRelationshipLabels().addAll(relEdge.getRelationshipLabels());
}
}
}
return graph;
}
示例8: mergeGraphEdges
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
/**
* @see org.splevo.vpm.analyzer.VPMAnalyzerService#mergeGraphs(java.util.List)
*
* {@inheritDoc}
*/
@Override
public void mergeGraphEdges(VPMGraph vpmGraph) {
for (Edge edge : vpmGraph.getEachEdge()) {
Node sourceNode = edge.getSourceNode();
Node targetNode = edge.getTargetNode();
// enrich the merge edge or create a new one
String edgeId = buildEdgeId(sourceNode, targetNode);
Edge mergeEdge = vpmGraph.getEdge(edgeId);
if (mergeEdge == null) {
mergeEdge = vpmGraph.addEdge(edgeId, sourceNode, targetNode);
for (String key : edge.getAttributeKeySet()) {
mergeEdge.addAttribute(key, edge.getAttribute(key));
}
} else {
RelationshipEdge relEdge = (RelationshipEdge) edge;
RelationshipEdge relMergeEdge = (RelationshipEdge) mergeEdge;
relMergeEdge.getRelationshipInfos().addAll(relEdge.getRelationshipInfos());
relMergeEdge.getRelationshipLabels().addAll(relEdge.getRelationshipLabels());
}
// remove the old merged node
vpmGraph.removeEdge(edge);
}
}
示例9: showShortestPath
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
public static void showShortestPath(Graph graph, Interpreter bsInterp, String fromNode, String toNode) {
// Edge lengths are stored in an attribute called "length" //layout.weight//
// The length of a path is the sum of the lengths of its edges
// The algorithm will store its results in attribute called "result"
Dijkstra dijkstra = new Dijkstra(Dijkstra.Element.EDGE, "result", "length");
dijkstra.init(graph);
dijkstra.setSource(graph.getNode(fromNode));
dijkstra.compute();
// Color all the nodes on the shortest path
for (Node node : dijkstra.getPathNodes(graph.getNode(toNode))) {
node.addAttribute("ui.style", "fill-color: #04756F; stroke-color: #2E0927;");
}
// Color all the edges in the shortest path
for (Edge edge : dijkstra.getPathEdges(graph.getNode(toNode))) {
edge.addAttribute("ui.style", "fill-color: #04756F;");
}
// change shape of source and target nodes
graph.getNode(fromNode).addAttribute("ui.style", "shape: box;");
graph.getNode(toNode).addAttribute("ui.style", "shape: box;");
// Print the shortest path
bsInterp.print(dijkstra.getPath(graph.getNode(toNode)).getNodePath() + "\n");
bsInterp.print(dijkstra.getPathLength(graph.getNode(toNode))+ "\n");
}
示例10: hideEdges
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
public void hideEdges() {
for(Edge edge : graph.getEachEdge()) {
edge.addAttribute("ui.hide");
}
}
示例11: addAttrib
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
public static void addAttrib (Edge edge, String a1, String a2) {
edge.addAttribute(a1, a2);
}
示例12: setupEdge
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
/**
* Setups an Edge.
*
* @param edge the edge to setup
* @param newLen the weight of the edge
*/
public void setupEdge(final Edge edge, final int newLen) {
edge.addAttribute("length", newLen);
}
示例13: updateEdge
import org.graphstream.graph.Edge; //导入方法依赖的package包/类
/**
* Updates an existing Edge.
*
* @param edge the edge to setup
* @param newLen the weight of the edge
*/
public void updateEdge(final Edge edge, final int newLen) {
edge.addAttribute("length", newLen);
}