diff --git a/SeQuant/core/tensor_network.cpp b/SeQuant/core/tensor_network.cpp index 9f94d50ff..d30cf6543 100644 --- a/SeQuant/core/tensor_network.cpp +++ b/SeQuant/core/tensor_network.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -425,6 +426,8 @@ TensorNetwork::make_bliss_graph( const auto &named_indices = named_indices_ptr == nullptr ? this->ext_indices() : *named_indices_ptr; + VertexPainter colorizer(named_indices); + // results std::shared_ptr graph; std::vector vertex_labels( @@ -434,25 +437,6 @@ TensorNetwork::make_bliss_graph( std::vector vertex_type( edges_.size()); // the size will be updated - // N.B. Colors [0, 3 max rank + named_indices.size()) are reserved: - // 0 - the bra vertex (for particle 0, if bra is nonsymm, or for the entire - // bra, if (anti)symm) 1 - the bra vertex for particle 1, if bra is nonsymm - // ... - // max_rank - the ket vertex (for particle 0, if particle-asymmetric, or for - // the entire ket, if particle-symmetric) max_rank+1 - the ket vertex for - // particle 1, if particle-asymmetric - // ... - // 2 max_rank - the aux index - // ... - // 3 max_rank - first named index - // 3 max_rank + 1 - second named index - // ... - // N.B. For braket-symmetric tensors the ket vertices use the same indices as - // the bra vertices - auto nonreserved_color = [&named_indices](size_t color) -> bool { - return color >= 3 * max_rank + named_indices.size(); - }; - // compute # of vertices size_t nv = 0; size_t index_cnt = 0; @@ -470,17 +454,8 @@ TensorNetwork::make_bliss_graph( ++nv; // each index is a vertex vertex_labels.at(index_cnt) = idx.to_latex(); vertex_type.at(index_cnt) = VertexType::Index; - // assign color: named indices use reserved colors - const auto named_index_it = named_indices.find(idx); - if (named_index_it == - named_indices.end()) { // anonymous index? use Index::color - const auto idx_color = idx.color(); - assert(nonreserved_color(idx_color)); - vertex_color.at(index_cnt) = idx_color; - } else { - const auto named_index_rank = named_index_it - named_indices.begin(); - vertex_color.at(index_cnt) = 3 * max_rank + named_index_rank; - } + vertex_color.at(index_cnt) = colorizer(idx); + // each symmetric proto index bundle will have a vertex ... // for now only store the unique protoindex bundles in // symmetric_protoindex_bundles, then commit their data to @@ -507,11 +482,10 @@ TensorNetwork::make_bliss_graph( spbundle_label += L"}"; vertex_labels.push_back(spbundle_label); vertex_type.push_back(VertexType::SPBundle); - const auto idx_proto_indices_color = Index::proto_indices_color(bundle); - assert(nonreserved_color(idx_proto_indices_color)); - vertex_color.push_back(idx_proto_indices_color); + vertex_color.push_back(colorizer(bundle)); spbundle_cnt++; }); + // now account for vertex representation of tensors size_t tensor_cnt = 0; // this will map to tensor index to the first (core) vertex in its @@ -524,10 +498,8 @@ TensorNetwork::make_bliss_graph( const auto tlabel = label(*t); vertex_labels.emplace_back(tlabel); vertex_type.emplace_back(VertexType::TensorCore); - const auto t_color = hash::value(tlabel); - static_assert(sizeof(t_color) == sizeof(unsigned long int)); - assert(nonreserved_color(t_color)); - vertex_color.push_back(t_color); + vertex_color.push_back(colorizer(*t)); + // symmetric/antisymmetric tensors are represented by 3 more vertices: // - bra // - ket @@ -539,18 +511,24 @@ TensorNetwork::make_bliss_graph( std::wstring(L"bra") + to_wstring(bra_rank(tref)) + ((symmetry(tref) == Symmetry::antisymm) ? L"a" : L"s")); vertex_type.push_back(VertexType::TensorBra); - vertex_color.push_back(0); + vertex_color.push_back(colorizer(BraGroup{0})); vertex_labels.push_back( std::wstring(L"ket") + to_wstring(ket_rank(tref)) + ((symmetry(tref) == Symmetry::antisymm) ? L"a" : L"s")); vertex_type.push_back(VertexType::TensorKet); - vertex_color.push_back( - braket_symmetry(tref) == BraKetSymmetry::symm ? 0 : max_rank); + if (braket_symmetry(tref) == BraKetSymmetry::symm) { + // Use BraGroup for kets as well as they are supposed to be + // indistinguishable + vertex_color.push_back(colorizer(BraGroup{0})); + } else { + vertex_color.push_back(colorizer(KetGroup{0})); + } vertex_labels.push_back( std::wstring(L"bk") + ((symmetry(tref) == Symmetry::antisymm) ? L"a" : L"s")); vertex_type.push_back(VertexType::Particle); - vertex_color.push_back(t_color); + // Color bk node in same color as tensor core + vertex_color.push_back(colorizer(tref)); } // nonsymmetric tensors are represented by 3*rank more vertices (with rank = // max(bra_rank(),ket_rank()) @@ -562,18 +540,24 @@ TensorNetwork::make_bliss_graph( auto pstr = to_wstring(p + 1); vertex_labels.push_back(std::wstring(L"bra") + pstr); vertex_type.push_back(VertexType::TensorBra); - const bool t_is_particle_symmetric = + const bool distinguishable_particles = particle_symmetry(tref) == ParticleSymmetry::nonsymm; - const auto bra_color = t_is_particle_symmetric ? p : 0; - vertex_color.push_back(bra_color); + vertex_color.push_back( + colorizer(BraGroup{distinguishable_particles ? p : 0})); vertex_labels.push_back(std::wstring(L"ket") + pstr); vertex_type.push_back(VertexType::TensorKet); - vertex_color.push_back(braket_symmetry(tref) == BraKetSymmetry::symm - ? bra_color - : bra_color + max_rank); + if (braket_symmetry(tref) == BraKetSymmetry::symm) { + // Use BraGroup for kets as well as they are supposed to be + // indistinguishable + vertex_color.push_back( + colorizer(BraGroup{distinguishable_particles ? p : 0})); + } else { + vertex_color.push_back( + colorizer(KetGroup{distinguishable_particles ? p : 0})); + } vertex_labels.push_back(std::wstring(L"bk") + pstr); vertex_type.push_back(VertexType::Particle); - vertex_color.push_back(t_color); + vertex_color.push_back(colorizer(tref)); } } // aux indices currently do not support any symmetry @@ -583,8 +567,7 @@ TensorNetwork::make_bliss_graph( auto pstr = to_wstring(p + 1); vertex_labels.push_back(std::wstring(L"aux") + pstr); vertex_type.push_back(VertexType::TensorAux); - const auto color = 2 * max_rank + p; - vertex_color.push_back(color); + vertex_color.push_back(colorizer(AuxGroup{p})); } ++tensor_cnt; @@ -659,21 +642,8 @@ TensorNetwork::make_bliss_graph( ++tensor_cnt; }); - // compress vertex colors to 32 bits, as required by Bliss, by hashing - size_t v_cnt = 0; - for (auto &&color : vertex_color) { - auto hash6432shift = [](size_t key) { - static_assert(sizeof(key) == 8); - key = (~key) + (key << 18); // key = (key << 18) - key - 1; - key = key ^ (key >> 31); - key = key * 21; // key = (key + (key << 2)) + (key << 4); - key = key ^ (key >> 11); - key = key + (key << 6); - key = key ^ (key >> 22); - return static_cast(key); - }; - graph->change_color(v_cnt, hash6432shift(color)); - ++v_cnt; + for (const auto [vertex, color] : ranges::views::enumerate(vertex_color)) { + graph->change_color(vertex, color); } return {graph, vertex_labels, vertex_color, vertex_type}; diff --git a/tests/unit/test_canonicalize.cpp b/tests/unit/test_canonicalize.cpp index a1e909fe4..77284c749 100644 --- a/tests/unit/test_canonicalize.cpp +++ b/tests/unit/test_canonicalize.cpp @@ -104,7 +104,7 @@ TEST_CASE("Canonicalizer", "[algorithms]") { canonicalize(input); REQUIRE_THAT( input, - SimplifiesTo("S{a1,a3;i1,i2} f{a2;i3} t{i3;a3} t{i1,i2;a1,a2}")); + SimplifiesTo("S{a1,a2;i1,i2} f{a3;i3} t{i3;a2} t{i1,i2;a1,a3}")); } { auto input = @@ -149,7 +149,7 @@ TEST_CASE("Canonicalizer", "[algorithms]") { canonicalize(input1); REQUIRE_THAT( input1, - SimplifiesTo("S{a1,a3;i1,i2} f{a2;i3} f⁺{a1,a3;i1,i3} t{i2;a2}")); + SimplifiesTo("S{a1,a2;i1,i3} f{a3;i2} f⁺{a1,a2;i1,i2} t{i3;a3}")); auto input2 = ex(L"S", bra{L"a_1", L"a_2"}, ket{L"i_1", L"i_2"}, Symmetry::nonsymm) * @@ -160,7 +160,7 @@ TEST_CASE("Canonicalizer", "[algorithms]") { REQUIRE_THAT( input2, SimplifiesTo( - "1/2 w S{a1,a3;i1,i2} f{a2;i3} f⁺{a1,a3;i1,i3} t{i2;a2}")); + "1/2 w S{a1,a2;i1,i3} f{a3;i2} f⁺{a1,a2;i1,i2} t{i3;a3}")); } } { @@ -190,8 +190,9 @@ TEST_CASE("Canonicalizer", "[algorithms]") { Symmetry::nonsymm) * ex(L"t", bra{L"p_3"}, ket{L"p_1"}, Symmetry::nonsymm) * ex(L"t", bra{L"p_4"}, ket{L"p_2"}, Symmetry::nonsymm); + simplify(input); canonicalize(input); - REQUIRE_THAT(input, SimplifiesTo("g{p2,p3;p1,p4} t{p1;p2} t{p4;p3}")); + REQUIRE_THAT(input, SimplifiesTo("g{p3,p4;p1,p2} t{p1;p3} t{p2;p4}")); } // CASE 2: Symmetric tensors @@ -268,7 +269,7 @@ TEST_CASE("Canonicalizer", "[algorithms]") { canonicalize(input); REQUIRE(input->size() == 1); REQUIRE_THAT(input, - SimplifiesTo("g{i3,i4;a3,i1} t{a2;i3} t{a1,a3;i4,i2}")); + SimplifiesTo("g{i3,i4;i1,a3} t{a2;i4} t{a1,a3;i3,i2}")); } { // Case 5: CCSDT R3: S3 * F * T3 @@ -369,10 +370,10 @@ TEST_CASE("Canonicalizer", "[algorithms]") { Symmetry::nonsymm); canonicalize(input); - REQUIRE(input->size() == 1); + simplify(input); REQUIRE_THAT( input, - SimplifiesTo("t{a2;i3} t{a1,a3;i4,i2} B{i3;a3;p5} B{i4;i1;p5}")); + SimplifiesTo("t{a2;i4} t{a1,a3;i3,i2} B{i3;i1;p5} B{i4;a3;p5}")); } } } diff --git a/tests/unit/test_tensor_network.cpp b/tests/unit/test_tensor_network.cpp index 23f810d2e..8b004c177 100644 --- a/tests/unit/test_tensor_network.cpp +++ b/tests/unit/test_tensor_network.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -134,9 +135,9 @@ TEST_CASE("TensorNetwork", "[elements]") { // to_latex(std::dynamic_pointer_cast(tn.tensors()[1])) << // std::endl; REQUIRE(to_latex(std::dynamic_pointer_cast(tn.tensors()[0])) == - L"{F^{{i_1}}_{{i_2}}}"); + L"{F^{{i_2}}_{{i_1}}}"); REQUIRE(to_latex(std::dynamic_pointer_cast(tn.tensors()[1])) == - L"{\\tilde{a}^{{i_2}}_{{i_1}}}"); + L"{\\tilde{a}^{{i_1}}_{{i_2}}}"); REQUIRE(tn.idxrepl().size() == 2); } @@ -216,199 +217,202 @@ TEST_CASE("TensorNetwork", "[elements]") { std::basic_ostringstream oss; REQUIRE_NOTHROW(graph->write_dot(oss, vlabels)); // std::wcout << "oss.str() = " << std::endl << oss.str() << std::endl; - REQUIRE(oss.str() == - L"graph g {\n" - "v0 [label=\"{a_1}\"; style=filled; color=\"#64facf\"; " - "fillcolor=\"#64facf80\"; penwidth=2];\n" - "v0 -- v29\n" - "v0 -- v58\n" - "v1 [label=\"{a_2}\"; style=filled; color=\"#64facf\"; " - "fillcolor=\"#64facf80\"; penwidth=2];\n" - "v1 -- v29\n" - "v1 -- v58\n" - "v2 [label=\"{a_3}\"; style=filled; color=\"#64facf\"; " - "fillcolor=\"#64facf80\"; penwidth=2];\n" - "v2 -- v33\n" - "v2 -- v54\n" - "v3 [label=\"{a_4}\"; style=filled; color=\"#64facf\"; " - "fillcolor=\"#64facf80\"; penwidth=2];\n" - "v3 -- v33\n" - "v3 -- v54\n" - "v4 [label=\"{a_5}\"; style=filled; color=\"#64facf\"; " - "fillcolor=\"#64facf80\"; penwidth=2];\n" - "v4 -- v37\n" - "v4 -- v50\n" - "v5 [label=\"{a_6}\"; style=filled; color=\"#64facf\"; " - "fillcolor=\"#64facf80\"; penwidth=2];\n" - "v5 -- v37\n" - "v5 -- v50\n" - "v6 [label=\"{a_7}\"; style=filled; color=\"#64facf\"; " - "fillcolor=\"#64facf80\"; penwidth=2];\n" - "v6 -- v22\n" - "v6 -- v41\n" - "v7 [label=\"{a_8}\"; style=filled; color=\"#64facf\"; " - "fillcolor=\"#64facf80\"; penwidth=2];\n" - "v7 -- v22\n" - "v7 -- v41\n" - "v8 [label=\"{i_1}\"; style=filled; color=\"#9c2a20\"; " - "fillcolor=\"#9c2a2080\"; penwidth=2];\n" - "v8 -- v30\n" - "v8 -- v57\n" - "v9 [label=\"{i_2}\"; style=filled; color=\"#9c2a20\"; " - "fillcolor=\"#9c2a2080\"; penwidth=2];\n" - "v9 -- v30\n" - "v9 -- v57\n" - "v10 [label=\"{i_3}\"; style=filled; color=\"#9c2a20\"; " - "fillcolor=\"#9c2a2080\"; penwidth=2];\n" - "v10 -- v34\n" - "v10 -- v53\n" - "v11 [label=\"{i_4}\"; style=filled; color=\"#9c2a20\"; " - "fillcolor=\"#9c2a2080\"; penwidth=2];\n" - "v11 -- v34\n" - "v11 -- v53\n" - "v12 [label=\"{i_5}\"; style=filled; color=\"#9c2a20\"; " - "fillcolor=\"#9c2a2080\"; penwidth=2];\n" - "v12 -- v38\n" - "v12 -- v49\n" - "v13 [label=\"{i_6}\"; style=filled; color=\"#9c2a20\"; " - "fillcolor=\"#9c2a2080\"; penwidth=2];\n" - "v13 -- v38\n" - "v13 -- v49\n" - "v14 [label=\"{i_7}\"; style=filled; color=\"#9c2a20\"; " - "fillcolor=\"#9c2a2080\"; penwidth=2];\n" - "v14 -- v21\n" - "v14 -- v42\n" - "v15 [label=\"{i_8}\"; style=filled; color=\"#9c2a20\"; " - "fillcolor=\"#9c2a2080\"; penwidth=2];\n" - "v15 -- v21\n" - "v15 -- v42\n" - "v16 [label=\"{\\kappa_1}\"; style=filled; color=\"#7126de\"; " - "fillcolor=\"#7126de80\"; penwidth=2];\n" - "v16 -- v25\n" - "v16 -- v46\n" - "v17 [label=\"{\\kappa_2}\"; style=filled; color=\"#7126de\"; " - "fillcolor=\"#7126de80\"; penwidth=2];\n" - "v17 -- v25\n" - "v17 -- v46\n" - "v18 [label=\"{\\kappa_3}\"; style=filled; color=\"#7126de\"; " - "fillcolor=\"#7126de80\"; penwidth=2];\n" - "v18 -- v26\n" - "v18 -- v45\n" - "v19 [label=\"{\\kappa_4}\"; style=filled; color=\"#7126de\"; " - "fillcolor=\"#7126de80\"; penwidth=2];\n" - "v19 -- v26\n" - "v19 -- v45\n" - "v20 [label=\"A\"; style=filled; color=\"#518020\"; " - "fillcolor=\"#51802080\"; penwidth=2];\n" - "v20 -- v23\n" - "v21 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v21 -- v23\n" - "v22 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v22 -- v23\n" - "v23 [label=\"bka\"; style=filled; color=\"#518020\"; " - "fillcolor=\"#51802080\"; penwidth=2];\n" - "v24 [label=\"g\"; style=filled; color=\"#2e0351\"; " - "fillcolor=\"#2e035180\"; penwidth=2];\n" - "v24 -- v27\n" - "v25 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v25 -- v27\n" - "v26 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v26 -- v27\n" - "v27 [label=\"bka\"; style=filled; color=\"#2e0351\"; " - "fillcolor=\"#2e035180\"; penwidth=2];\n" - "v28 [label=\"t\"; style=filled; color=\"#043e44\"; " - "fillcolor=\"#043e4480\"; penwidth=2];\n" - "v28 -- v31\n" - "v29 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v29 -- v31\n" - "v30 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v30 -- v31\n" - "v31 [label=\"bka\"; style=filled; color=\"#043e44\"; " - "fillcolor=\"#043e4480\"; penwidth=2];\n" - "v32 [label=\"t\"; style=filled; color=\"#043e44\"; " - "fillcolor=\"#043e4480\"; penwidth=2];\n" - "v32 -- v35\n" - "v33 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v33 -- v35\n" - "v34 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v34 -- v35\n" - "v35 [label=\"bka\"; style=filled; color=\"#043e44\"; " - "fillcolor=\"#043e4480\"; penwidth=2];\n" - "v36 [label=\"t\"; style=filled; color=\"#043e44\"; " - "fillcolor=\"#043e4480\"; penwidth=2];\n" - "v36 -- v39\n" - "v37 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v37 -- v39\n" - "v38 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v38 -- v39\n" - "v39 [label=\"bka\"; style=filled; color=\"#043e44\"; " - "fillcolor=\"#043e4480\"; penwidth=2];\n" - "v40 [label=\"ã\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v40 -- v43\n" - "v41 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v41 -- v43\n" - "v42 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v42 -- v43\n" - "v43 [label=\"bka\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v44 [label=\"ã\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v44 -- v47\n" - "v45 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v45 -- v47\n" - "v46 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v46 -- v47\n" - "v47 [label=\"bka\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v48 [label=\"ã\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v48 -- v51\n" - "v49 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v49 -- v51\n" - "v50 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v50 -- v51\n" - "v51 [label=\"bka\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v52 [label=\"ã\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v52 -- v55\n" - "v53 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v53 -- v55\n" - "v54 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v54 -- v55\n" - "v55 [label=\"bka\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v56 [label=\"ã\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "v56 -- v59\n" - "v57 [label=\"bra2a\"; style=filled; color=\"#eaa2ab\"; " - "fillcolor=\"#eaa2ab80\"; penwidth=2];\n" - "v57 -- v59\n" - "v58 [label=\"ket2a\"; style=filled; color=\"#5a8fd3\"; " - "fillcolor=\"#5a8fd380\"; penwidth=2];\n" - "v58 -- v59\n" - "v59 [label=\"bka\"; style=filled; color=\"#cbfbe5\"; " - "fillcolor=\"#cbfbe580\"; penwidth=2];\n" - "}\n"); + const std::wstring actual = oss.str(); + const std::wstring expected = + L"graph g {\n" + L"v0 [label=\"{a_1}\"; style=filled; color=\"#2603c0\"; " + L"fillcolor=\"#2603c080\"; penwidth=2];\n" + L"v0 -- v29\n" + L"v0 -- v58\n" + L"v1 [label=\"{a_2}\"; style=filled; color=\"#2603c0\"; " + L"fillcolor=\"#2603c080\"; penwidth=2];\n" + L"v1 -- v29\n" + L"v1 -- v58\n" + L"v2 [label=\"{a_3}\"; style=filled; color=\"#2603c0\"; " + L"fillcolor=\"#2603c080\"; penwidth=2];\n" + L"v2 -- v33\n" + L"v2 -- v54\n" + L"v3 [label=\"{a_4}\"; style=filled; color=\"#2603c0\"; " + L"fillcolor=\"#2603c080\"; penwidth=2];\n" + L"v3 -- v33\n" + L"v3 -- v54\n" + L"v4 [label=\"{a_5}\"; style=filled; color=\"#2603c0\"; " + L"fillcolor=\"#2603c080\"; penwidth=2];\n" + L"v4 -- v37\n" + L"v4 -- v50\n" + L"v5 [label=\"{a_6}\"; style=filled; color=\"#2603c0\"; " + L"fillcolor=\"#2603c080\"; penwidth=2];\n" + L"v5 -- v37\n" + L"v5 -- v50\n" + L"v6 [label=\"{a_7}\"; style=filled; color=\"#2603c0\"; " + L"fillcolor=\"#2603c080\"; penwidth=2];\n" + L"v6 -- v22\n" + L"v6 -- v41\n" + L"v7 [label=\"{a_8}\"; style=filled; color=\"#2603c0\"; " + L"fillcolor=\"#2603c080\"; penwidth=2];\n" + L"v7 -- v22\n" + L"v7 -- v41\n" + L"v8 [label=\"{i_1}\"; style=filled; color=\"#103109\"; " + L"fillcolor=\"#10310980\"; penwidth=2];\n" + L"v8 -- v30\n" + L"v8 -- v57\n" + L"v9 [label=\"{i_2}\"; style=filled; color=\"#103109\"; " + L"fillcolor=\"#10310980\"; penwidth=2];\n" + L"v9 -- v30\n" + L"v9 -- v57\n" + L"v10 [label=\"{i_3}\"; style=filled; color=\"#103109\"; " + L"fillcolor=\"#10310980\"; penwidth=2];\n" + L"v10 -- v34\n" + L"v10 -- v53\n" + L"v11 [label=\"{i_4}\"; style=filled; color=\"#103109\"; " + L"fillcolor=\"#10310980\"; penwidth=2];\n" + L"v11 -- v34\n" + L"v11 -- v53\n" + L"v12 [label=\"{i_5}\"; style=filled; color=\"#103109\"; " + L"fillcolor=\"#10310980\"; penwidth=2];\n" + L"v12 -- v38\n" + L"v12 -- v49\n" + L"v13 [label=\"{i_6}\"; style=filled; color=\"#103109\"; " + L"fillcolor=\"#10310980\"; penwidth=2];\n" + L"v13 -- v38\n" + L"v13 -- v49\n" + L"v14 [label=\"{i_7}\"; style=filled; color=\"#103109\"; " + L"fillcolor=\"#10310980\"; penwidth=2];\n" + L"v14 -- v21\n" + L"v14 -- v42\n" + L"v15 [label=\"{i_8}\"; style=filled; color=\"#103109\"; " + L"fillcolor=\"#10310980\"; penwidth=2];\n" + L"v15 -- v21\n" + L"v15 -- v42\n" + L"v16 [label=\"{\\kappa_1}\"; style=filled; color=\"#0d4103\"; " + L"fillcolor=\"#0d410380\"; penwidth=2];\n" + L"v16 -- v25\n" + L"v16 -- v46\n" + L"v17 [label=\"{\\kappa_2}\"; style=filled; color=\"#0d4103\"; " + L"fillcolor=\"#0d410380\"; penwidth=2];\n" + L"v17 -- v25\n" + L"v17 -- v46\n" + L"v18 [label=\"{\\kappa_3}\"; style=filled; color=\"#0d4103\"; " + L"fillcolor=\"#0d410380\"; penwidth=2];\n" + L"v18 -- v26\n" + L"v18 -- v45\n" + L"v19 [label=\"{\\kappa_4}\"; style=filled; color=\"#0d4103\"; " + L"fillcolor=\"#0d410380\"; penwidth=2];\n" + L"v19 -- v26\n" + L"v19 -- v45\n" + L"v20 [label=\"A\"; style=filled; color=\"#bd2ec1\"; " + L"fillcolor=\"#bd2ec180\"; penwidth=2];\n" + L"v20 -- v23\n" + L"v21 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v21 -- v23\n" + L"v22 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v22 -- v23\n" + L"v23 [label=\"bka\"; style=filled; color=\"#bd2ec1\"; " + L"fillcolor=\"#bd2ec180\"; penwidth=2];\n" + L"v24 [label=\"g\"; style=filled; color=\"#120912\"; " + L"fillcolor=\"#12091280\"; penwidth=2];\n" + L"v24 -- v27\n" + L"v25 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v25 -- v27\n" + L"v26 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v26 -- v27\n" + L"v27 [label=\"bka\"; style=filled; color=\"#120912\"; " + L"fillcolor=\"#12091280\"; penwidth=2];\n" + L"v28 [label=\"t\"; style=filled; color=\"#4b7e1b\"; " + L"fillcolor=\"#4b7e1b80\"; penwidth=2];\n" + L"v28 -- v31\n" + L"v29 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v29 -- v31\n" + L"v30 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v30 -- v31\n" + L"v31 [label=\"bka\"; style=filled; color=\"#4b7e1b\"; " + L"fillcolor=\"#4b7e1b80\"; penwidth=2];\n" + L"v32 [label=\"t\"; style=filled; color=\"#4b7e1b\"; " + L"fillcolor=\"#4b7e1b80\"; penwidth=2];\n" + L"v32 -- v35\n" + L"v33 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v33 -- v35\n" + L"v34 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v34 -- v35\n" + L"v35 [label=\"bka\"; style=filled; color=\"#4b7e1b\"; " + L"fillcolor=\"#4b7e1b80\"; penwidth=2];\n" + L"v36 [label=\"t\"; style=filled; color=\"#4b7e1b\"; " + L"fillcolor=\"#4b7e1b80\"; penwidth=2];\n" + L"v36 -- v39\n" + L"v37 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v37 -- v39\n" + L"v38 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v38 -- v39\n" + L"v39 [label=\"bka\"; style=filled; color=\"#4b7e1b\"; " + L"fillcolor=\"#4b7e1b80\"; penwidth=2];\n" + L"v40 [label=\"ã\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v40 -- v43\n" + L"v41 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v41 -- v43\n" + L"v42 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v42 -- v43\n" + L"v43 [label=\"bka\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v44 [label=\"ã\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v44 -- v47\n" + L"v45 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v45 -- v47\n" + L"v46 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v46 -- v47\n" + L"v47 [label=\"bka\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v48 [label=\"ã\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v48 -- v51\n" + L"v49 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v49 -- v51\n" + L"v50 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v50 -- v51\n" + L"v51 [label=\"bka\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v52 [label=\"ã\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v52 -- v55\n" + L"v53 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v53 -- v55\n" + L"v54 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v54 -- v55\n" + L"v55 [label=\"bka\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v56 [label=\"ã\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"v56 -- v59\n" + L"v57 [label=\"bra2a\"; style=filled; color=\"#6ecb7d\"; " + L"fillcolor=\"#6ecb7d80\"; penwidth=2];\n" + L"v57 -- v59\n" + L"v58 [label=\"ket2a\"; style=filled; color=\"#cfd472\"; " + L"fillcolor=\"#cfd47280\"; penwidth=2];\n" + L"v58 -- v59\n" + L"v59 [label=\"bka\"; style=filled; color=\"#e024b7\"; " + L"fillcolor=\"#e024b780\"; penwidth=2];\n" + L"}\n"; + + REQUIRE(actual == expected); // compute automorphism group { @@ -424,21 +428,23 @@ TEST_CASE("TensorNetwork", "[elements]") { &save_aut); std::basic_ostringstream oss; bliss::print_auts(aut_generators, oss, decltype(vlabels){}); - REQUIRE(oss.str() == - L"(14,15)\n" - "(6,7)\n" - "(18,19)\n" - "(16,17)\n" - "(8,9)\n" - "(0,1)\n" - "(10,11)\n" - "(12,13)\n" - "(2,3)\n" - "(4,5)\n" - "(2,4)(3,5)(10,12)(11,13)(32,36)(33,37)(34,38)(35,39)(48,52)(49," - "53)(50,54)(51,55)\n" - "(0,2)(1,3)(8,10)(9,11)(28,32)(29,33)(30,34)(31,35)(52,56)(53,57)" - "(54,58)(55,59)\n"); + const std::wstring actual = oss.str(); + const std::wstring expected = + L"(18,19)\n" + L"(16,17)\n" + L"(14,15)\n" + L"(6,7)\n" + L"(12,13)\n" + L"(4,5)\n" + L"(10,11)\n" + L"(8,9)\n" + L"(2,3)\n" + L"(0,1)\n" + L"(0,2)(1,3)(8,10)(9,11)(28,32)(29,33)(30,34)(31,35)(52,56)(53,57)(" + L"54,58)(55,59)\n" + L"(2,4)(3,5)(10,12)(11,13)(32,36)(33,37)(34,38)(35,39)(48,52)(49,53)(" + L"50,54)(51,55)\n"; + REQUIRE(actual == expected); // change to 1 to user vertex labels rather than indices if (0) {