Exemplo n.º 1
0
    def sub_graph_matching(self, subgraph, known_match, validate=False):
        """Finds all the matching subgraphs in the graph

        In case the known_match has a subgraph edge with property
        "negative_condition" then run subgraph matching on the edge vertices
        and unite the results.
        Otherwise just run subgraph matching and return its result.

        :param subgraph: the subgraph to match
        :param known_match: starting point at the subgraph and the graph
        :param validate:
        :return: all the matching subgraphs in the graph
        """
        sge = known_match.subgraph_element
        ge = known_match.graph_element

        if not known_match.is_vertex and sge.get(NEG_CONDITION):
            source_matches = self._filtered_subgraph_matching(
                ge.source_id, sge.source_id, subgraph, validate)
            target_matches = self._filtered_subgraph_matching(
                ge.target_id, sge.target_id, subgraph, validate)

            return self._list_union(source_matches, target_matches)
        else:
            return subgraph_matching(self.graph, subgraph, [known_match],
                                     validate)
Exemplo n.º 2
0
    def _filtered_subgraph_matching(self, ge_v_id, sge_v_id, subgraph,
                                    validate):
        """Runs subgraph_matching on edges vertices with filtering

        Runs subgraph_matching on edges vertices after checking if that vertex
        has real neighbors in the entity graph.
        """
        if self.graph.neighbors(
                ge_v_id, edge_attr_filter={EProps.VITRAGE_IS_DELETED: False}):
            template_vertex = subgraph.get_vertex(sge_v_id)
            graph_vertex = self.graph.get_vertex(ge_v_id)
            match = Mapping(template_vertex, graph_vertex, True)
            return subgraph_matching(self.graph, subgraph, [match], validate)

        return []
Exemplo n.º 3
0
 def sub_graph_matching(self, subgraph, known_matches, validate=False):
     return subgraph_matching(self.graph, subgraph, known_matches, validate)
Exemplo n.º 4
0
 def sub_graph_matching(self, subgraph, known_matches, validate=False):
     return subgraph_matching(self.graph, subgraph, known_matches, validate)