Search in sources :

Example 1 with EnergyTerm

use of org.vcell.util.graphlayout.energybased.EnergySum.EnergyTerm in project vcell by virtualcell.

the class AllNodePairsEnergyTermFactory method generateTerms.

public Set<EnergyTerm> generateTerms(ContainedGraph graph) {
    Set<SetOfTwo<Node>> nodePairs = new HashSet<SetOfTwo<Node>>();
    for (Node node1 : graph.getNodes()) {
        for (Node node2 : graph.getNodes()) {
            if (node1 != node2 && (acrossContainers || node1.getContainer() == node2.getContainer())) {
                SetOfTwo<Node> nodePair = new SetOfTwo<Node>(node1, node2);
                if (!nodePairs.contains(nodePair)) {
                    nodePairs.add(nodePair);
                }
            }
        }
    }
    HashSet<EnergyTerm> terms = new HashSet<EnergyTerm>();
    for (SetOfTwo<Node> nodePair : nodePairs) {
        terms.add(new EnergyTerm.Default(new ListOfTwo<Node>(nodePair.getElement1(), nodePair.getElement2()), function));
    }
    return terms;
}
Also used : EnergyTerm(org.vcell.util.graphlayout.energybased.EnergySum.EnergyTerm) SetOfTwo(org.sbpax.util.sets.SetOfTwo) ListOfTwo(org.vcell.sybil.util.lists.ListOfTwo) Node(org.vcell.util.graphlayout.ContainedGraph.Node) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 SetOfTwo (org.sbpax.util.sets.SetOfTwo)1 ListOfTwo (org.vcell.sybil.util.lists.ListOfTwo)1 Node (org.vcell.util.graphlayout.ContainedGraph.Node)1 EnergyTerm (org.vcell.util.graphlayout.energybased.EnergySum.EnergyTerm)1