use of org.graphstream.graph.Edge in project abstools by abstools.
the class MyGMLWriter method writeAll.
public synchronized void writeAll(Graph g, File file) throws FileNotFoundException {
pw = new PrintWriter(new FileOutputStream(file));
pw.println("Creator " + escape("ABS Graph Writer"));
pw.println("graph [");
for (Node n : g.getNodeSet()) {
writeNode(n);
}
for (Edge e : g.getEdgeSet()) {
writeEdge(e);
}
pw.println("]");
pw.close();
pw = null;
}
use of org.graphstream.graph.Edge in project gs-ui-javafx by graphstream.
the class TestSprite method chooseNextEdge.
public void chooseNextEdge() {
Edge edge = (Edge) getAttachment();
Node node = edge.getSourceNode();
if (dir > 0)
node = edge.getTargetNode();
Edge next = randomEdge(node);
double pos = 0;
if (node == next.getSourceNode()) {
dir = 0.01f;
pos = 0;
} else {
dir = -0.01f;
pos = 1;
}
attachToEdge(next.getId());
setPosition(pos);
}
use of org.graphstream.graph.Edge in project abstools by abstools.
the class MyGMLWriter method addEdge.
@Override
public synchronized void addEdge(ObjectView source, ObjectView target, boolean cog) {
String edgeName = getID(source) + "-" + getID(target);
Edge e = graph.getEdge(edgeName);
if (e == null || (!cog && e.getAttribute("kind").equals("cog"))) {
e = graph.addEdge(edgeName, getID(source), getID(target), true);
e.addAttribute("count", 1);
if (cog) {
e.addAttribute("ui.class", "cog");
e.addAttribute("kind", "cog");
e.addAttribute("weight", 5);
} else {
e.addAttribute("ui.class", "usage");
e.addAttribute("kind", "usage");
e.addAttribute("weight", 1);
}
} else {
int c = (Integer) e.getAttribute("count");
e.setAttribute("count", c + 1);
System.out.println("Count = " + (c + 1));
}
}
use of org.graphstream.graph.Edge in project fmv by f-agu.
the class FilterGraphUI method createOrGetEdge.
/**
* @param label
* @param labeledFC
* @param node
* @return
*/
private Edge createOrGetEdge(Label label, FilterComplex labeledFC, Node node) {
String edgeKey = getEdgeKey(label, labeledFC);
Edge edge = graph.getEdge(edgeKey);
if (edge == null) {
Node inNode = createOrGetNode(labeledFC);
edge = graph.addEdge(edgeKey, inNode, node);
edge.addAttribute("ui.label", edgeKey);
}
return edge;
}
use of org.graphstream.graph.Edge in project fmv by f-agu.
the class FilterGraphUI method addRoot.
// **************************************************
/**
*/
private void addRoot() {
Map<InputProcessor, Node> inputProcessorNodeMap = new HashMap<>();
operation.getInputProcessorStream().forEach(ip -> {
for (OutputKey outputKey : ip.getOutputKeys()) {
Node node = createRootNode(ip, outputKey);
inputProcessorNodeMap.put(ip, node);
}
});
for (FilterComplex rootFC : filterGraph.getRoots()) {
Map<IOKey, In> inputMap = rootFC.getInputMap();
if (!inputMap.isEmpty()) {
for (Entry<IOKey, In> entry : inputMap.entrySet()) {
FilterInput filterInput = entry.getValue().getFilterInput();
if (filterInput instanceof InputProcessor) {
Node node = inputProcessorNodeMap.get(filterInput);
Edge edge = graph.addEdge(node.getId() + "-" + rootFC.toString(), createOrGetNode(rootFC), node);
// edge.addAttribute("ui.label", values);
}
}
}
}
}
Aggregations