Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:56:37+00:00 2026-06-14T20:56:37+00:00

For example, these two graphs is considered to be a perfect partial match: 0

  • 0

For example, these two graphs is considered to be a perfect partial match:

0 – 1

1 – 2

2 – 3

3 – 0

AND

0 – 1

1 – 2

These two are considered a bad match

0 – 1

1 – 2

2 – 3

3 – 0

AND

0 – 1

1 – 2

2 – 0

The numbers don’t have to match, as long as the relation between those nodes can perfectly match.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:56:38+00:00Added an answer on June 14, 2026 at 8:56 pm

    This is the subgraph isomorphism problem: http://en.wikipedia.org/wiki/Subgraph_isomorphism_problem

    There is one algorithm mentioned in the article due to Ullmann.

    Ullmann’s algorithm is an extension of a depth-first search. A depth-first search would work like this:

    def search(graph,subgraph,assignments):
      i=len(assignments)
    
      # Make sure that every edge between assigned vertices in the subgraph is also an
      # edge in the graph.
      for edge in subgraph.edges:
        if edge.first<i and edge.second<i:
          if not graph.has_edge(assignments[edge.first],assignments[edge.second]):
            return False
    
      # If all the vertices in the subgraph are assigned, then we are done.
      if i==subgraph.n_vertices:
        return True
    
      # Otherwise, go through all the possible assignments for the next vertex of
      # the subgraph and try it.
      for j in possible_assignments[i]:
        if j not in assignments:
          assignments.append(j)
          if search(graph,subgraph,assignments):
            # This worked, so we've found an isomorphism.
            return True
          assignments.pop()
    
    def find_isomorphism(graph,subgraph):
      assignments=[]
      if search(graph,subgraph,assignments):
        return assignments
      return None
    

    For the basic algorithm, possible_assignments[i] = range(0,graph.n_vertices). That is, all the vertices are a possibility.

    Ullmann extends this basic algorithm by narrowing the possibilities:

    def update_possible_assignments(graph,subgraph,possible_assignments):
      any_changes=True
      while any_changes:
        any_changes = False
        for i in range(0,len(subgraph.n_vertices)):
          for j in possible_assignments[i]:
            for x in subgraph.adjacencies(i):
              match=False
              for y in range(0,len(graph.n_vertices)):
                if y in possible_assignments[x] and graph.has_edge(j,y):
                  match=True
              if not match:
                possible_assignments[i].remove(j)
                any_changes = True
    

    The idea is that if node i of the subgraph could possibly match node j of the graph, then for every node x that is adjacent to node i in the subgraph, it has to be possible to find a node y that is adjacent to node j in the graph. This process helps more than might first be obvious, because each time we eliminate a possible assignment, this may cause other possible assignments to be eliminated, since they are interdependent.

    The final algorithm is then:

    def search(graph,subgraph,assignments,possible_assignments):
      update_possible_assignments(graph,subgraph,possible_assignments)
    
      i=len(assignments)
    
      # Make sure that every edge between assigned vertices in the subgraph is also an
      # edge in the graph.
      for edge in subgraph.edges:
        if edge.first<i and edge.second<i:
          if not graph.has_edge(assignments[edge.first],assignments[edge.second]):
            return False
    
      # If all the vertices in the subgraph are assigned, then we are done.
      if i==subgraph.n_vertices:
        return True
    
      for j in possible_assignments[i]:
        if j not in assignments:
          assignments.append(j)
    
          # Create a new set of possible assignments, where graph node j is the only 
          # possibility for the assignment of subgraph node i.
          new_possible_assignments = deep_copy(possible_assignments)
          new_possible_assignments[i] = [j]
    
          if search(graph,subgraph,assignments,new_possible_assignments):
            return True
    
          assignments.pop()
        possible_assignments[i].remove(j)
        update_possible_assignments(graph,subgraph,possible_assignments)
    
    def find_isomorphism(graph,subgraph):
      assignments=[]
      possible_assignments = [[True]*graph.n_vertices for i in range(subgraph.n_vertices)]
      if search(graph,subgraph,assignments,possible_assignments):
        return assignments
      return None
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is easier to explain with an example. Given these two classes: public class
I have updated my website. Previously there were links like these: http://example.com/bla-bla-bla?language=de . After
I have two branches in my application: 01 02 When I tag from these
I'm still learning about DDD and I have these two (probably simple) questions: If
I have two graphs and I am trying to overlay one on top of
In the GEF shapes example, there are two types of connections, they differ by
There is an example on php.net how to get last two domain segments in
I'm using doxygen for commenting code. There is, for example, two files: test1.cpp :
Is there any difference between the following two examples and should one be preferred
Can anyone give me an example of these attributes in action: stroke-dasharray, stroke-linecap, stroke-linejoin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.