@Test public void testConnect() { initLists(); parameters.add("P5"); parameters.add("Q5"); parameters.add("i+2"); dialog.connect2ListsFormula(parameters, c20); for (int i = 0; i <= 0; i++) assertTrue(c20.getVertexById(i).getOutgoingNeighbours().contains(c20.getVertexById(i + 5 + 2))); parameters.clear(); parameters.add("P5"); parameters.add("Q5"); parameters.add("i^2"); dialog.connect2ListsFormula(parameters, c20); for (int i = 0; i <= 0; i++) assertTrue(c20.getVertexById(i).getOutgoingNeighbours().contains(c20.getVertexById(i * i + 5))); parameters.clear(); }
public void connect2ListsFormula(ArrayList<String> parameters, Structure structure) { if (!existsVertexList(parameters.get(0))) { errorMsg = "No such vertex list: " + parameters.get(0); return; } if (!existsVertexList(parameters.get(1))) { errorMsg = "No such vertex list: " + parameters.get(1); return; } ArrayList<Vertex> list1 = findVertexList(parameters.get(0)); ArrayList<Vertex> list2 = findVertexList(parameters.get(1)); for (int i = 0; i < list1.size(); i++) { net.objecthunter.exp4j.Expression expression = new net.objecthunter.exp4j.ExpressionBuilder(parameters.get(2)) .variable("i") .build() .setVariable("i", i); double jDouble = expression.evaluate(); int j = (int) Math.floor(jDouble); if (0 <= j && j < list2.size()) structure.addEdge(list1.get(i), list2.get(j)); else { errorMsg = errorMsg + "Result of applying formula to " + i + " out of list " + parameters.get(1) + ". Skipping " + i + ".\n"; } } }
Dialog { public void connect2ListsFormula(ArrayList<String> parameters, Structure structure) { if (!existsVertexList(parameters.get(0))) { errorMsg = "No such vertex list: " + parameters.get(0); return; } if (!existsVertexList(parameters.get(1))) { errorMsg = "No such vertex list: " + parameters.get(1); return; } ArrayList<Vertex> list1 = findVertexList(parameters.get(0)); ArrayList<Vertex> list2 = findVertexList(parameters.get(1)); for (int i = 0; i < list1.size(); i++) { net.objecthunter.exp4j.Expression expression = new net.objecthunter.exp4j.ExpressionBuilder(parameters.get(2)) .variable("i") .build() .setVariable("i", i); double jDouble = expression.evaluate(); int j = (int) Math.floor(jDouble); if (0 <= j && j < list2.size()) structure.addEdge(list1.get(i), list2.get(j)); else { errorMsg = errorMsg + "Result of applying formula to " + i + " out of list " + parameters.get(1) + ". Skipping " + i + ".\n"; } } } }
Dialog { public void connect2ListsFormula(ArrayList<String> parameters, Structure structure) { if (!existsVertexList(parameters.get(0))) { errorMsg = "No such vertex list: " + parameters.get(0); return; } if (!existsVertexList(parameters.get(1))) { errorMsg = "No such vertex list: " + parameters.get(1); return; } ArrayList<Vertex> list1 = findVertexList(parameters.get(0)); ArrayList<Vertex> list2 = findVertexList(parameters.get(1)); for (int i = 0; i < list1.size(); i++) { net.objecthunter.exp4j.Expression expression = new net.objecthunter.exp4j.ExpressionBuilder(parameters.get(2)) .variable("i") .build() .setVariable("i", i); double jDouble = expression.evaluate(); int j = (int) Math.floor(jDouble); if (0 <= j && j < list2.size()) structure.addEdge(list1.get(i), list2.get(j)); else { errorMsg = errorMsg + "Result of applying formula to " + i + " out of list " + parameters.get(1) + ". Skipping " + i + ".\n"; } } } Dialog(List<GralogList<Vertex>> allCollectionVertex, List<GralogList<Edge>> allCollectionEdge);  Dialog(); }
Dialog { public void connect2ListsFormula(ArrayList<String> parameters, Structure structure) { if (!existsVertexList(parameters.get(0))) { errorMsg = "No such vertex list: " + parameters.get(0); return; } if (!existsVertexList(parameters.get(1))) { errorMsg = "No such vertex list: " + parameters.get(1); return; } ArrayList<Vertex> list1 = findVertexList(parameters.get(0)); ArrayList<Vertex> list2 = findVertexList(parameters.get(1)); for (int i = 0; i < list1.size(); i++) { net.objecthunter.exp4j.Expression expression = new net.objecthunter.exp4j.ExpressionBuilder(parameters.get(2)) .variable("i") .build() .setVariable("i", i); double jDouble = expression.evaluate(); int j = (int) Math.floor(jDouble); if (0 <= j && j < list2.size()) structure.addEdge(list1.get(i), list2.get(j)); else { errorMsg = errorMsg + "Result of applying formula to " + i + " out of list " + parameters.get(1) + ". Skipping " + i + ".\n"; } } } Dialog(List<GralogList<Vertex>> allCollectionVertex, List<GralogList<Edge>> allCollectionEdge);  Dialog(); @Deprecated Map<String, ArrayList<Vertex>> getVertexListS(); @Deprecated Map<String, ArrayList<Edge>> getEdgeListS(); void printLists(ArrayList<String> parameters); void twoListsOp(ArrayList<String> parameters); void delete(ArrayList<String> parameters); void complement(ArrayList<String> parameters, Structure structure); void sort(ArrayList<String> parameters); void connectClique(ArrayList<String> parameters, Structure structure); void connectTClosure(ArrayList<String> parameters, Structure structure); void connectSelfloop(ArrayList<String> parameters, Structure structure); void connectPath(ArrayList<String> parameters, Structure structure); void connectCycle(ArrayList<String> parameters, Structure structure); void connectBiclique(ArrayList<String> parameters, Structure structure); void connectMatching(ArrayList<String> parameters, Structure structure); void connectFormula(ArrayList<String> parameters, Structure structure); void connect2ListsFormula(ArrayList<String> parameters, Structure structure); boolean existsVertexList(String s); boolean existsEdgeList(String s); GralogList<Vertex> findVertexList(String s); GralogList<Edge> findEdgeList(String s); void filter(ArrayList<String> parameters, Structure structure, Highlights highlights); String getErrorMsg(); void setErrorMsg(String s); boolean addVertex(Vertex v); boolean removeVertex(Vertex v); boolean addEdge(Edge e); boolean removeEdge(Edge e); }
Dialog { public void connect2ListsFormula(ArrayList<String> parameters, Structure structure) { if (!existsVertexList(parameters.get(0))) { errorMsg = "No such vertex list: " + parameters.get(0); return; } if (!existsVertexList(parameters.get(1))) { errorMsg = "No such vertex list: " + parameters.get(1); return; } ArrayList<Vertex> list1 = findVertexList(parameters.get(0)); ArrayList<Vertex> list2 = findVertexList(parameters.get(1)); for (int i = 0; i < list1.size(); i++) { net.objecthunter.exp4j.Expression expression = new net.objecthunter.exp4j.ExpressionBuilder(parameters.get(2)) .variable("i") .build() .setVariable("i", i); double jDouble = expression.evaluate(); int j = (int) Math.floor(jDouble); if (0 <= j && j < list2.size()) structure.addEdge(list1.get(i), list2.get(j)); else { errorMsg = errorMsg + "Result of applying formula to " + i + " out of list " + parameters.get(1) + ". Skipping " + i + ".\n"; } } } Dialog(List<GralogList<Vertex>> allCollectionVertex, List<GralogList<Edge>> allCollectionEdge);  Dialog(); @Deprecated Map<String, ArrayList<Vertex>> getVertexListS(); @Deprecated Map<String, ArrayList<Edge>> getEdgeListS(); void printLists(ArrayList<String> parameters); void twoListsOp(ArrayList<String> parameters); void delete(ArrayList<String> parameters); void complement(ArrayList<String> parameters, Structure structure); void sort(ArrayList<String> parameters); void connectClique(ArrayList<String> parameters, Structure structure); void connectTClosure(ArrayList<String> parameters, Structure structure); void connectSelfloop(ArrayList<String> parameters, Structure structure); void connectPath(ArrayList<String> parameters, Structure structure); void connectCycle(ArrayList<String> parameters, Structure structure); void connectBiclique(ArrayList<String> parameters, Structure structure); void connectMatching(ArrayList<String> parameters, Structure structure); void connectFormula(ArrayList<String> parameters, Structure structure); void connect2ListsFormula(ArrayList<String> parameters, Structure structure); boolean existsVertexList(String s); boolean existsEdgeList(String s); GralogList<Vertex> findVertexList(String s); GralogList<Edge> findEdgeList(String s); void filter(ArrayList<String> parameters, Structure structure, Highlights highlights); String getErrorMsg(); void setErrorMsg(String s); boolean addVertex(Vertex v); boolean removeVertex(Vertex v); boolean addEdge(Edge e); boolean removeEdge(Edge e);  }