2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-19 04:12:11 +00:00

Merge pull request #429 from jan-grimo/fix-github-428

Fix multiplicity value comparison
This commit is contained in:
Jeremy W. Murphy
2025-05-12 17:55:19 +09:00
committed by GitHub
4 changed files with 394 additions and 1 deletions

View File

@@ -91,7 +91,7 @@ namespace detail
assert(x_multiplicity_iter != multiplicity->end());
auto y_multiplicity_iter = multiplicity->find(invariant1(y));
assert(y_multiplicity_iter != multiplicity->end());
return *x_multiplicity_iter < *y_multiplicity_iter;
return x_multiplicity_iter->second < y_multiplicity_iter->second;
}
Invariant1 invariant1;
const InvariantCountMap* multiplicity;

175
test/github-428-0.dot Normal file
View File

@@ -0,0 +1,175 @@
digraph G {
0;
1;
2;
3;
4;
5;
6;
7;
8;
9;
10;
11;
12;
13;
14;
15;
16;
17;
18;
19;
20;
21;
22;
23;
24;
25;
26;
27;
28;
29;
30;
31;
32;
33;
34;
35;
36;
37;
38;
39;
40;
41;
42;
43;
44;
45;
46;
47;
48;
49;
50;
51;
52;
53;
54;
55;
56;
57;
58;
59;
60;
61;
62;
63;
64;
65;
66;
67;
68;
69;
70;
71;
72;
73;
74;
6->23 ;
0->23 ;
6->24 ;
0->24 ;
6->25 ;
1->25 ;
6->26 ;
1->26 ;
6->27 ;
2->27 ;
6->28 ;
2->28 ;
6->29 ;
3->29 ;
6->30 ;
3->30 ;
6->31 ;
4->31 ;
6->32 ;
4->32 ;
6->33 ;
5->33 ;
6->34 ;
5->34 ;
6->35 ;
0->35 ;
7->36 ;
1->36 ;
8->37 ;
3->37 ;
9->38 ;
3->38 ;
10->39 ;
3->39 ;
11->40 ;
3->40 ;
12->41 ;
3->41 ;
13->42 ;
3->42 ;
17->43 ;
3->43 ;
14->44 ;
3->44 ;
15->45 ;
3->45 ;
16->46 ;
3->46 ;
18->47 ;
3->47 ;
19->48 ;
3->48 ;
20->49 ;
3->49 ;
21->50 ;
3->50 ;
22->51 ;
3->51 ;
35->52 ;
69->52 ;
36->53 ;
70->53 ;
37->54 ;
72->54 ;
38->55 ;
72->55 ;
39->56 ;
72->56 ;
40->57 ;
72->57 ;
41->58 ;
72->58 ;
42->59 ;
72->59 ;
43->60 ;
72->60 ;
44->61 ;
72->61 ;
45->62 ;
72->62 ;
46->63 ;
72->63 ;
47->64 ;
72->64 ;
48->65 ;
72->65 ;
49->66 ;
72->66 ;
50->67 ;
72->67 ;
51->68 ;
72->68 ;
24->69 ;
26->70 ;
28->71 ;
30->72 ;
32->73 ;
34->74 ;
}

175
test/github-428-1.dot Normal file
View File

@@ -0,0 +1,175 @@
digraph G {
0;
1;
2;
3;
4;
5;
6;
7;
8;
9;
10;
11;
12;
13;
14;
15;
16;
17;
18;
19;
20;
21;
22;
23;
24;
25;
26;
27;
28;
29;
30;
31;
32;
33;
34;
35;
36;
37;
38;
39;
40;
41;
42;
43;
44;
45;
46;
47;
48;
49;
50;
51;
52;
53;
54;
55;
56;
57;
58;
59;
60;
61;
62;
63;
64;
65;
66;
67;
68;
69;
70;
71;
72;
73;
74;
6->23 ;
0->23 ;
6->24 ;
0->24 ;
6->25 ;
1->25 ;
6->26 ;
1->26 ;
6->27 ;
2->27 ;
6->28 ;
2->28 ;
6->29 ;
3->29 ;
6->30 ;
3->30 ;
6->31 ;
4->31 ;
6->32 ;
4->32 ;
6->33 ;
5->33 ;
6->34 ;
5->34 ;
6->35 ;
0->35 ;
7->36 ;
1->36 ;
10->37 ;
3->37 ;
11->38 ;
3->38 ;
12->39 ;
3->39 ;
13->40 ;
3->40 ;
17->41 ;
3->41 ;
14->42 ;
3->42 ;
15->43 ;
3->43 ;
16->44 ;
3->44 ;
18->45 ;
3->45 ;
19->46 ;
3->46 ;
20->47 ;
3->47 ;
21->48 ;
3->48 ;
22->49 ;
3->49 ;
8->50 ;
3->50 ;
9->51 ;
3->51 ;
35->52 ;
69->52 ;
36->53 ;
70->53 ;
37->54 ;
72->54 ;
38->55 ;
72->55 ;
39->56 ;
72->56 ;
40->57 ;
72->57 ;
41->58 ;
72->58 ;
42->59 ;
72->59 ;
43->60 ;
72->60 ;
44->61 ;
72->61 ;
45->62 ;
72->62 ;
46->63 ;
72->63 ;
47->64 ;
72->64 ;
48->65 ;
72->65 ;
49->66 ;
72->66 ;
50->67 ;
72->67 ;
51->68 ;
72->68 ;
24->69 ;
26->70 ;
28->71 ;
30->72 ;
32->73 ;
34->74 ;
}

View File

@@ -31,6 +31,10 @@
#include <boost/random/mersenne_twister.hpp>
#include <boost/lexical_cast.hpp>
#define BOOST_GRAPH_USE_SPIRIT_PARSER
#include <boost/property_map/dynamic_property_map.hpp>
#include <boost/graph/graphviz.hpp>
#ifndef BOOST_NO_CXX11_HDR_RANDOM
#include <random>
typedef std::mt19937 random_generator_type;
@@ -404,12 +408,51 @@ void test_colored_isomorphism(int n, double edge_probability)
}
}
struct VertexProps
{
std::string node_id; // will store "0", "1", ..., "74"
};
using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VertexProps>;
void loadGraphFromDOT(const std::string& filename, Graph& g)
{
std::ifstream in(filename);
if (!in)
{
throw std::runtime_error("Error: Cannot open file ");
}
auto node_id_map = boost::get(&VertexProps::node_id, g);
boost::dynamic_properties dp;
dp.property("node_id", node_id_map);
if (!boost::read_graphviz(in, g, dp))
{
throw std::runtime_error("Error: Failed to read DOT ");
}
}
void test_github_issue_428()
{
using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VertexProps>;
Graph g0;
Graph g1;
loadGraphFromDOT("github-428-0.dot", g0);
loadGraphFromDOT("github-428-1.dot", g1);
const bool iso = boost::isomorphism(g0, g1);
BOOST_TEST(iso);
}
int main(int argc, char* argv[])
{
int n = argc < 3 ? 30 : boost::lexical_cast< int >(argv[1]);
double edge_prob = argc < 3 ? 0.45 : boost::lexical_cast< double >(argv[2]);
test_isomorphism(n, edge_prob);
test_colored_isomorphism(n, edge_prob);
test_github_issue_428();
return boost::report_errors();
}