Comments (5)
Also, it is not correct to make sure ALL edges from existing to new vertices are equivalent. At least one edge from existing to new vertices is equivalent is enough.
from graph.
Hi, I noticed the same issue.
For what it's worth, here is the example given in the 1982 McGregor paper "Backtrack Search Algorithms and the Maximal Common Subgraph Problem"
I.e., the correspondence here should be
1 <-> 1
2 <-> 2
3 <-> 3
4 <-> 4
5 <-> 5
6 <-> 7 (*)
7 <-> 8
8 <-> 6
(*) It appears that 6 <-> 7
should be included, even though they share no edges. This also makes sense, as the paper states that every node of the smaller graph should be included in the correspondence
G_1 has p_1 nodes [...] G_2 has p_2 nodes [...]. We shall assume [...] that p_1 <= p_2 and that every node in G_1 must therefore be included in the correspondence.
I tried to reproduce this with the boost implementation (note that code uses 0-based indexing, whereas the paper is 1-based):
#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/mcgregor_common_subgraphs.hpp>
using namespace boost;
typedef adjacency_list<vecS, vecS, undirectedS> Graph;
typedef adjacency_list<> DiGraph;
template<typename GraphFirst,
typename GraphSecond>
struct print_callback {
print_callback(const GraphFirst &graph1,
const GraphSecond &graph2) :
m_graph1(graph1), m_graph2(graph2) {}
template<typename CorrespondenceMapFirstToSecond,
typename CorrespondenceMapSecondToFirst>
bool operator()(CorrespondenceMapFirstToSecond correspondence_map_1_to_2,
CorrespondenceMapSecondToFirst correspondence_map_2_to_1,
typename graph_traits<GraphFirst>::vertices_size_type subgraph_size) {
// Print out correspondences between vertices
BGL_FORALL_VERTICES_T(vertex1, m_graph1, GraphFirst) {
// Skip unmapped vertices
if (get(correspondence_map_1_to_2, vertex1) != graph_traits<GraphSecond>::null_vertex()) {
std::cout << vertex1 << " <-> " << get(correspondence_map_1_to_2, vertex1) << std::endl;
}
}
std::cout << "---" << std::endl;
return (true);
}
private:
const GraphFirst &m_graph1;
const GraphSecond &m_graph2;
};
int main() {
std::vector<std::pair<int, int>> g1_edges = {
{0, 1}, {0, 2}, {1, 2}, {1, 3}, {1, 4}, {2, 5}, {2, 7}, {3, 6}, {4, 6}, {4, 7}
};
std::vector<std::pair<int, int>> g2_edges = {
{0, 1}, {0, 2}, {1, 3}, {1, 4}, {2, 5}, {3, 6}, {4, 5}, {4, 7}
};
Graph G1(g1_edges.begin(), g1_edges.end(), 8);
Graph G2(g2_edges.begin(), g2_edges.end(), 8);
std::cout << "Graph G1:" << std::endl;
for (auto v : G1.vertex_set()) {
std::cout << "\t" << v << ": ";
for (auto e: G1.out_edge_list(v)) {
std::cout << e.get_target() << ", ";
}
std::cout << std::endl;
}
std::cout << "Graph G2:" << std::endl;
for (auto v : G2.vertex_set()) {
std::cout << "\t" << v << ": ";
for (auto e: G2.out_edge_list(v)) {
std::cout << e.get_target() << ", ";
}
std::cout << std::endl;
}
print_callback<Graph, Graph> my_callback(G1, G2);
mcgregor_common_subgraphs_maximum_unique(G1, G2, false, my_callback);
return 0;
}
from graph.
what is your cmake setting and your boost version? Are you using boost managed by conda environment?
from graph.
Yes vf2 seems to be wrong,
Here is my code
Clearly there is atleast one subgraph isomer in my data.
But it finds none
I am not even using mcgregor. I a just running your subgraph isomer example with a different data
Ideone's Boost Version is 1.65.1
from graph.
If you don't know the solution to the problem, you can still help greatly by creating a pull request with a good unit test that demonstrates the problem. Sometimes, that's half-way to fixing it.
from graph.
Related Issues (20)
- A mistake in r_c_shortest_paths_example.cpp HOT 1
- `depth_first_visit_impl`: `finish_edge` not invoked when it should on MSVC HOT 2
- Algorithm for generating a random Flow Network/Graph HOT 1
- [Feature request] Implementation of Held-Karp lower bound for the TSP HOT 1
- Improve docs for ResourceExtensionFunction in r_c_shortest_paths
- Boost.Graph no longer builds with C++03 HOT 6
- astar_search does unnecessary initialization of vertices
- broken link to example for reverse graph adaptor HOT 6
- adjacency_matrix::add_vertex always aborts in Debug mode ? HOT 2
- Single-path RCSP does not return always the shortest path HOT 7
- Stack-overflow in boost::read_graphviz_detail::parser::parse_subgraph HOT 23
- Option to allow `breadth_first_search` to use `in_edges`
- Question on negative flow on arcs in Boykin-Kolmogorov algorithm -- meaning and interpretation
- Modular Boost C++ Libraries Request HOT 1
- read_graphml function rejecting well formed Graphml files HOT 1
- If using Boost::subgraph. Don't use Vertex_index_t.
- New near-linear time algorithm to solve the minimum cut problem for undirected graphs HOT 8
- CSR: Indexed properties maps are unstable
- creation of nested subgraphs by vertex descriptors is broken/unintuitive HOT 4
- kruskal_minimum_spanning_tree not working on filtered graph with weight map as named property
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graph.