123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package org.insa.graphs.algorithm.weakconnectivity;
-
- import java.util.ArrayList;
-
- import org.insa.graphs.algorithm.AbstractSolution;
- import org.insa.graphs.model.Node;
-
- public class WeaklyConnectedComponentsSolution extends AbstractSolution {
-
- // Components
- private ArrayList<ArrayList<Node>> components;
-
- protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData data) {
- super(data);
- }
-
- protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData data, Status status,
- ArrayList<ArrayList<Node>> components) {
- super(data, status);
- this.components = components;
- }
-
- @Override
- public WeaklyConnectedComponentsData getInputData() {
- return (WeaklyConnectedComponentsData) super.getInputData();
- }
-
- /**
- * @return Components of the solution, if any.
- */
- public ArrayList<ArrayList<Node>> getComponents() {
- return components;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- int nIsolated = 0;
- int nGt10 = 0;
- for (ArrayList<Node> component: components) {
- if (component.size() == 1) {
- nIsolated += 1;
- }
- else if (component.size() > 10) {
- nGt10 += 1;
- }
- }
- return "Found " + components.size() + " components (" + nGt10 + " with more than 10 nodes, "
- + nIsolated + " isolated nodes) in " + getSolvingTime().getSeconds() + " seconds.";
-
- }
-
- }
|