test_class.file: singa-mathematics/src/test/java/bio/singa/mathematics/algorithms/graphs/SmallestSetOfSmallestRingsFinderTest.java
test_class.identifier: SmallestSetOfSmallestRingsFinderTest
test_case.body: @Test
      void findSmallestRings() {
          GenericGraph<Integer> testGraph1 = new GenericGraph<>();
          testGraph1.addNode(1);
          testGraph1.addNode(2);
          testGraph1.addNode(3);
          testGraph1.addNode(4);
          testGraph1.addNode(5);
          testGraph1.addNode(6);
          testGraph1.addNode(7);
          testGraph1.addEdgeBetween(1, 2);
          testGraph1.addEdgeBetween(1, 5);
          testGraph1.addEdgeBetween(2, 5);
          testGraph1.addEdgeBetween(2, 3);
          testGraph1.addEdgeBetween(3, 4);
          testGraph1.addEdgeBetween(4, 5);
          testGraph1.addEdgeBetween(6, 4);
          testGraph1.addEdgeBetween(7, 1);
  
          SmallestSetOfSmallestRingsFinder<GenericNode<Integer>, GenericEdge<Integer>, Vector2D, Integer, GenericGraph<Integer>> ringFinder = new SmallestSetOfSmallestRingsFinder<>(testGraph1);
          assertEquals(2, ringFinder.getRings().size());
          assertEquals(3, ringFinder.getRings().get(0).size());
          assertEquals(4, ringFinder.getRings().get(1).size());
      }
test_case.class_method_signature: SmallestSetOfSmallestRingsFinderTest.findSmallestRings()
test_case.full_signature: @Test void findSmallestRings()
test_case.identifier: findSmallestRings
test_case.invocations: addNode addNode addNode addNode addNode addNode addNode addEdgeBetween addEdgeBetween addEdgeBetween addEdgeBetween addEdgeBetween addEdgeBetween addEdgeBetween addEdgeBetween assertEquals size getRings assertEquals size get getRings assertEquals size get getRings
test_case.modifiers: @Test
test_case.parameters: ()
test_case.return: void
test_case.signature: void findSmallestRings()
focal_class.declarator: logger = LoggerFactory.getLogger(SmallestSetOfSmallestRingsFinder.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(SmallestSetOfSmallestRingsFinder.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: graph
focal_class.modifier: private final
focal_class.original_string: private final GraphType graph;
focal_class.type: GraphType
focal_class.var_name: graph
focal_class.declarator: rings
focal_class.modifier: private
focal_class.original_string: private List<Set<NodeType>> rings;
focal_class.type: List<Set<NodeType>>
focal_class.var_name: rings
focal_class.file: singa-mathematics/src/main/java/bio/singa/mathematics/algorithms/graphs/SmallestSetOfSmallestRingsFinder.java
focal_class.identifier: SmallestSetOfSmallestRingsFinder
focal_class.class_method_signature: SmallestSetOfSmallestRingsFinder.SmallestSetOfSmallestRingsFinder(GraphType graph)
focal_class.full_signature: public  SmallestSetOfSmallestRingsFinder(GraphType graph)
focal_class.identifier: SmallestSetOfSmallestRingsFinder
focal_class.modifiers: public
focal_class.parameters: (GraphType graph)
focal_class.signature:  SmallestSetOfSmallestRingsFinder(GraphType graph)
focal_class.class_method_signature: SmallestSetOfSmallestRingsFinder.getRings()
focal_class.full_signature: public List<Set<NodeType>> getRings()
focal_class.identifier: getRings
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<Set<NodeType>>
focal_class.signature: List<Set<NodeType>> getRings()
focal_class.class_method_signature: SmallestSetOfSmallestRingsFinder.findSmallestRings()
focal_class.full_signature: private void findSmallestRings()
focal_class.identifier: findSmallestRings
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void findSmallestRings()
focal_class.class_method_signature: SmallestSetOfSmallestRingsFinder.findRing(GraphType graph, NodeType rootNode)
focal_class.full_signature: private Set<NodeType> findRing(GraphType graph, NodeType rootNode)
focal_class.identifier: findRing
focal_class.modifiers: private
focal_class.parameters: (GraphType graph, NodeType rootNode)
focal_class.return: Set<NodeType>
focal_class.signature: Set<NodeType> findRing(GraphType graph, NodeType rootNode)
focal_method.body: private void findSmallestRings() {
  
          // reduce nodes that only have a single connection (cannot be part of any ring)
          List<NodeType> nodesToRemove = graph.getNodes().stream()
                  .filter(node -> node.getNeighbours().size() < 2)
                  .collect(Collectors.toList());
  
          GraphType graphCopy = (GraphType) graph.getCopy();
          nodesToRemove.forEach(graphCopy::removeNode);
  
          rings = new ArrayList<>();
          for (NodeType node : graphCopy.getNodes()) {
              // BFS for each node in the graph
              Set<NodeType> ring = findRing(graphCopy, node);
              if (ring != null && !rings.contains(ring)) {
                  rings.add(ring);
              }
          }
  
          if (!rings.isEmpty()) {
              rings.sort(Comparator.comparing(Set::size));
              logger.info("identified {} rings in the input graph (smallest one of size: {})", rings.size(), rings.get(0).size());
          }
      }
focal_method.class_method_signature: SmallestSetOfSmallestRingsFinder.findSmallestRings()
focal_method.full_signature: private void findSmallestRings()
focal_method.identifier: findSmallestRings
focal_method.invocations: collect filter stream getNodes size getNeighbours toList getCopy forEach getNodes findRing contains add isEmpty sort comparing info size size get
focal_method.modifiers: private
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void findSmallestRings()