Loading autocnet/graph/network.py +18 −0 Original line number Diff line number Diff line Loading @@ -698,3 +698,21 @@ class CandidateGraph(nx.Graph): H.graph = self.graph return H def subgraph_from_matches(self): """ Returns a sub-graph where all edges have matches. (i.e. images with no matches are removed) Returns ------- : Object A networkX graph object """ # get all edges that have matches matches = [(u, v) for u, v, edge in self.edges_iter(data=True) if hasattr(edge, 'matches') and not edge.matches.empty] return self.create_edge_subgraph(matches) autocnet/graph/tests/test_network.py +9 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,15 @@ class TestCandidateGraph(unittest.TestCase): node_sub = g.create_node_subgraph([0,1]) self.assertEqual(len(node_sub), 2) def test_subgraph_from_matches(self): test_sub_graph = self.graph.create_node_subgraph([0, 1]) test_sub_graph.extract_features(extractor_parameters={'nfeatures': 500}) test_sub_graph.match_features(k=2) sub_graph_from_matches = self.graph.subgraph_from_matches() self.assertEqual(test_sub_graph.edges(), sub_graph_from_matches.edges()) def tearDown(self): pass Loading Loading
autocnet/graph/network.py +18 −0 Original line number Diff line number Diff line Loading @@ -698,3 +698,21 @@ class CandidateGraph(nx.Graph): H.graph = self.graph return H def subgraph_from_matches(self): """ Returns a sub-graph where all edges have matches. (i.e. images with no matches are removed) Returns ------- : Object A networkX graph object """ # get all edges that have matches matches = [(u, v) for u, v, edge in self.edges_iter(data=True) if hasattr(edge, 'matches') and not edge.matches.empty] return self.create_edge_subgraph(matches)
autocnet/graph/tests/test_network.py +9 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,15 @@ class TestCandidateGraph(unittest.TestCase): node_sub = g.create_node_subgraph([0,1]) self.assertEqual(len(node_sub), 2) def test_subgraph_from_matches(self): test_sub_graph = self.graph.create_node_subgraph([0, 1]) test_sub_graph.extract_features(extractor_parameters={'nfeatures': 500}) test_sub_graph.match_features(k=2) sub_graph_from_matches = self.graph.subgraph_from_matches() self.assertEqual(test_sub_graph.edges(), sub_graph_from_matches.edges()) def tearDown(self): pass Loading