use of org.gephi.io.importer.api.EdgeDraft in project gephi by gephi.
the class ImporterTGF method addEdge.
private void addEdge(String source, String target, String label) {
NodeDraft sourceNode;
if (!container.nodeExists(source)) {
sourceNode = container.factory().newNodeDraft(source);
container.addNode(sourceNode);
} else {
sourceNode = container.getNode(source);
}
NodeDraft targetNode;
if (!container.nodeExists(target)) {
targetNode = container.factory().newNodeDraft(target);
container.addNode(targetNode);
} else {
targetNode = container.getNode(target);
}
if (!container.edgeExists(sourceNode.getId(), targetNode.getId())) {
EdgeDraft edge = container.factory().newEdgeDraft();
edge.setSource(sourceNode);
edge.setTarget(targetNode);
edge.setLabel(label);
container.addEdge(edge);
}
}
use of org.gephi.io.importer.api.EdgeDraft in project gephi by gephi.
the class ImporterTLP method parseEdge.
private void parseEdge(String[] tokens, int cptLine) {
if (tokens.length != 4) {
report.logIssue(new Issue(NbBundle.getMessage(ImporterGDF.class, "importerTPL_error_dataformat1", cptLine), Issue.Level.WARNING));
}
String id = tokens[1];
EdgeDraft edge = container.factory().newEdgeDraft(id);
NodeDraft source = container.getNode(tokens[2]);
NodeDraft target = container.getNode(tokens[3]);
edge.setSource(source);
edge.setTarget(target);
container.addEdge(edge);
}
use of org.gephi.io.importer.api.EdgeDraft in project gephi by gephi.
the class ImporterVNA method addEdge.
private void addEdge(String[] edgeData) {
NodeDraft sourceNode;
if (!container.nodeExists(edgeData[0])) {
sourceNode = container.factory().newNodeDraft(edgeData[0]);
container.addNode(sourceNode);
} else {
sourceNode = container.getNode(edgeData[0]);
}
NodeDraft targetNode;
if (!container.nodeExists(edgeData[1])) {
targetNode = container.factory().newNodeDraft(edgeData[1]);
container.addNode(targetNode);
} else {
targetNode = container.getNode(edgeData[1]);
}
EdgeDraft edge = container.factory().newEdgeDraft();
edge.setSource(sourceNode);
edge.setTarget(targetNode);
int i = 0;
try {
for (i = 2; i < edgeData.length; i++) {
switch(tieAttributes[i]) {
case EDGE_STRENGTH:
float weight = Float.parseFloat(edgeData[i]);
if (edgeWidthFunction != null) {
weight = edgeWidthFunction.computeTransformation(weight);
}
edge.setWeight(weight);
break;
case OTHER:
edge.parseAndSetValue(tieDataColumns[i].getId(), edgeData[i]);
break;
}
}
} catch (NumberFormatException e) {
report.logIssue(new Issue("Error parsing numerical value at '" + edgeData[i] + "'.", Issue.Level.WARNING));
}
container.addEdge(edge);
}
Aggregations