Permalink
Browse files

API change : the AbstractVertexSignature now has a new abstract metho…

…d to convert edge labels to colors
  • Loading branch information...
gilleain committed Apr 7, 2013
1 parent 62cee7b commit 8485990be9434d78a65b6329bd332c6287c90fb3
@@ -215,26 +215,14 @@ private void addNode(int layer, DAG.Node parentNode, int vertexIndex,
int originalParentIndex =
getOriginalVertexIndex(parentNode.vertexIndex);
String edgeLabel = getEdgeLabel(originalParentIndex, vertexIndex);
- int edgeColor = convertLabelToColor(edgeLabel);
+ int edgeColor = convertEdgeLabelToColor(edgeLabel);
existingNode.addEdgeColor(parentNode.vertexIndex, edgeColor);
parentNode.addEdgeColor(mappedVertexIndex, edgeColor);
dag.addRelation(existingNode, parentNode);
layerArcs.add(arc);
}
- // XXX tmp
- private int convertLabelToColor(String label) {
- if (label.equals("-")) {
- return 1;
- } else if (label.equals("=")) {
- return 2;
- } else if (label.equals("#")) {
- return 3;
- }
- return 1;
- }
-
/**
* Convert this signature into a canonical signature string.
*
@@ -352,11 +340,22 @@ public int getVertexCount() {
return this.vertexCount;
}
+ /**
+ * Convert the edge label (if any) to an integer color, for example the bond
+ * order in a chemistry implementation.
+ *
+ * @param label
+ * the label for an edge
+ * @return an int color
+ */
+ protected abstract int convertEdgeLabelToColor(String label);
+
/**
* Get the integer label for a vertex - in chemistry implementations this
* will be the element mass.
*
- * @param vertexIndex the index of the vertex in the input graph
+ * @param vertexIndex
+ * the index of the vertex in the input graph
* @return an integer label
*/
protected abstract int getIntLabel(int vertexIndex);
@@ -64,4 +64,16 @@ public String getVertexSymbol(int vertexIndex) {
return this.molecule.getSymbolFor(vertexIndex);
}
+ @Override
+ protected int convertEdgeLabelToColor(String label) {
+ if (label.equals("-")) {
+ return 1;
+ } else if (label.equals("=")) {
+ return 2;
+ } else if (label.equals("#")) {
+ return 3;
+ }
+ return 1;
+ }
+
}
@@ -40,5 +40,10 @@ public String getVertexSymbol(int vertexIndex) {
protected int getIntLabel(int vertexIndex) {
return -1;
}
+
+ @Override
+ protected int convertEdgeLabelToColor(String label) {
+ return 1;
+ }
}

0 comments on commit 8485990

Please sign in to comment.