sehe / spirit-graphviz

related to https://stackoverflow.com/questions/46334463/how-to-use-boost-spirit-list-operator-with-mandatory-minimum-amount-of-elements/46365596#46365596
2 stars 0 forks source link

owner->id gives <Error reading characters of string.> #1

Closed didibib closed 1 year ago

didibib commented 1 year ago

I am loading in devonshiredebate_withclusters.dot which contains subgraphs. I want to know to which subgraph each node belongs. Each node has a owner, but when inspecting owner->id it says <Error reading characters of string.> in the inspector.

g->graph->subgraphs has size=11, so the subgraphs are found I assume.

... 
Model::MainGraph g = buildModel(into);

for (auto it = g.all_nodes.begin(); it != g.all_nodes.end(); it++)
{
  auto&  id = it->id();
  auto& node = it->node;
  auto& owner = it->owner->id;
}
sehe commented 1 year ago

What does "the inspector" mean?

didibib commented 1 year ago

The visual studio inspector, where I can view variables. inspector.

sehe commented 1 year ago

Why use a debugger? They are notoriously bad at dealing with optimizable variables. E.g. using my Vim to debug I can confirm:

image

Note <optimized out>.

Note this is even still the case with building at -O0 -fno-omit-frame-pointer. So, instead just print the information:

id:"n0" owner_id:"G"
id:"n1" owner_id:"G"
id:"n10" owner_id:"G"
id:"n100" owner_id:"G"
id:"n101" owner_id:"G"
id:"n102" owner_id:"G"
...
id:"n97" owner_id:"G"
id:"n98" owner_id:"G"
id:"n99" owner_id:"G"
Remaining unparsed input: '
'

Now this may not be what you expected, but I expect the expectation may be wrong. I've carefully compared the behavior of graphviz (courtesy libgraph) using the nop layout engine and they clearly suggest a complicated behavior where ownership isn't fixed during lexical parsing. I.e. if you reduce the input to be:

Just node declarations without edges in the main graph ``` digraph G { subgraph "Dating of the Main Culm" { n39 [description="Near Bideford (north Devon), the Main Culm strata support fossil plants which are characteristic of the Coal Measures period", title="Characteristic Coal Measures Fossils in Main Culm", type="statement-map-node"]; // ... n207 [description="If strata can be identified by means of their characteristic fossils assemblages and most of fossil species supported by the Main Culm strata are known from Coal Measures strata, then they are Coal Measures in age", title="No Main Culm as Coal Measures - Characteristic Fossils Assemblage Principle V2 - Devon – 2", type="argument-map-node"]; } subgraph "Dating of the Culm Limestone" { n94 [description="Some part of the black Culm Limestone is Coal Measures in age", title="Some Black Culm Limestone as Coal Measures", type="statement-map-node"]; // ... n224 [description="If strata can be identified by means of their characteristic fossils assemblages and most of the fossil species supported by Black Culm Limestone strata are known from Yorkshire Mountain Limestone strata, then they are are Mountain Limestone in age", title="Black Culm Limestone as Mountain Limestone - Characteristic Fossils Assemblage Principle V2 – 2", type="argument-map-node"]; } subgraph "Rocks, Fossils and Time" { n15 [description="For some time interval, there is (at least) one characteristic fossil species", title="Characteristic Fossil – Some Time", type="statement-map-node"]; // ... n166 [description="If, during some period p, there are local variations in sedimentation and some rock type is characteristic for some time interval dt iff, during dt, every region supports f, then, during p, there is no characteristic rock type", title="Characteristic Fossil and Local Variations in Fauna and Flora - Some Time", type="argument-map-node"]; } subgraph "Fossils in Pre-Old Red Sandston" { n11 [description="In pre-Old Red Sandstone strata, there are Carboniferous fossils", title="Carboniferous Fossils in pre-Old Red Sandstone Strata", type="statement-map-node"]; // ... n174 [description="If the Non-Culm strata are Old Red Sandstone in age and there are no Carboniferous fossils in Old Red Sandstone strata, then there are no Carboniferous fossils in the Non-Culm strata", title="Non-Culm as Old Red Sandstone – Carboniferous Fossils", type="argument-map-node"]; } subgraph "Other Regions Than Devonshire" { n67 [description="Near Pembrokeshire (southwest Wales), strata which are pre-Old Red Sandstone in appearance are of characteristic Cambrian rock type", title="Pembrokeshire - Characteristic Cambrian Rock Type", type="statement-map-node"]; // ... n188 [description="If strata can be identified by means of their characteristic fossils assemblages and some Old Red Sandstone strata support fossils intermediate in character between Silurian and Mountain Limestone as well as peculiar Old Red Sandstone fish, then such a fossils assemblage is characteristic of the Old Red Sandstone period", title="Russian Strata as Old Red Sandstone - Characteristic Fossils Assemblage Principle V2 – 2", type="argument-map-node"]; } subgraph "Youngest Devonian Strata" { n64 [description="Main Culm strata are at youngest Silurian in age", title="Main Culm at Youngest Silurian", type="statement-map-node"]; // ... n296 [description="If (i) originally, the younger sediments rest on older ones and (ii) some limestones are younger than Main Culm strata, Black Culm Limestone strata and the main part of the Non-Culm strata, respectively, then, given these strata are undisturbed, these limestones overlay Main Culm strata, Black Culm Limestone strata and the main part of Non-Culm strata, respectively", title="Tor Bay and Newton Abott – Temporal Order 3 – 2", type="argument-map-node"]; } subgraph "Gap in the Sequence of Devonshi" { n150 [description="The passage between Main Culm and Black Culm Limestone strata is conformable", title="Conformable Passage - Main Culm and Black Culm Limestone", type="statement-map-node"]; // ... n334 [description="If some southeast Devon limestones, being Old Red Sandstone in age, pass conformably into Main Culm strata, and there are no Silurian Main Culm strata, then, there are some Old Red Sandstone Main Culm strata", title="Main Culm Older Than Southeast Devon Limestones - Main Culm as Old Red Sandstone", type="argument-map-node"]; } subgraph Evidence { n2 [description="In Devon, all the strata - older than the New Red Sandstone - form an unbroken sequence of strata", title="Unbroken Sequence of Devon Strata", type="statement-map-node"]; // ... n30 [description="In the Valday Hills (Russia), some strata, sandwiched between undisturbed Silurian and Mountain Limestone strata, support both limestones with fossils intermediate in character between Silurian and Mountain Limestone and sandstones with peculiar Old Red Sandstone fish", title="Valday Hills", type="statement-map-node"]; } subgraph Universalities { n1 [description="Strata are originally formed from sediments that were deposited in flat horizontal sheets - the younger sediments deposited on older ones", title="Formation of Strata", type="statement-map-node"]; n0 [description="Given the strata are undisturbed, the Primary strata are overlain by Cambrian strata, Silurian strata, Old Red Sandstone strata, Mountain Limestone strata, Coal Measures strata, New Red Sandstone strata and Oolitic stata, respectively", title="Standard Sequence", type="statement-map-node"]; } subgraph "Old Red Sandstone Characteristi" { n40 [description="Some peculiar fish fossils are characteristic of the Old Red Sandstone period", title="Characteristic Fossils - Old Red Sandstone", type="statement-map-node"]; // ... n170 [description="If, given a sufficiently large (i) amount of fossils and (ii) region under study , Old Red Sandstone strata support a fossil species assemblage intermediate in character between those of Silurian strata and Mountain Limestone strata and a revised Lyellian Principle holds, then Old Red Sandstone is intermediate in age between Silurian and Mountain Limestone", title="Lyellian Principle – CFA Old Red Sandstone V2 - 2", type="argument-map-node"]; } subgraph "Dating of the Non-Culm" { n28 [description="Non-Culm strata support fossils intermediate in character between Silurian ans Mountain Limestone", title="Non-Culm – Fossils Assemblage -2", type="statement-map-node"]; // ... n248 [description="If strata can be identified by means of their characteristic fossils assemblages and Non-Culm strata support a fossils assemblage intermediate in character between those of Mountain Limestone strata than Silurian strata and Scottish Old Red Sandstone strata peculiar fish fossils only known from the Old Red Sandstone, then the Non-Culm strata are Old Red Sandstone in age.", title="Non-Culm and Scottish Strata as Old Red Sandstone - CFA ORS III V2 - 1", type="argument-map-node"]; } } ```

the output becomes

same nodes with owner_id the declaring subgraphs ``` Parse success id:"n0" owner_id:"Universalities" id:"n1" owner_id:"Universalities" id:"n10" owner_id:"Evidence" id:"n100" owner_id:"Dating of the Culm Limestone" id:"n101" owner_id:"Dating of the Culm Limestone" id:"n102" owner_id:"Dating of the Culm Limestone" id:"n103" owner_id:"Dating of the Culm Limestone" id:"n104" owner_id:"Dating of the Culm Limestone" id:"n105" owner_id:"Dating of the Culm Limestone" id:"n106" owner_id:"Youngest Devonian Strata" id:"n107" owner_id:"Dating of the Culm Limestone" id:"n108" owner_id:"Dating of the Culm Limestone" id:"n109" owner_id:"Dating of the Culm Limestone" id:"n11" owner_id:"Fossils in Pre-Old Red Sandston" id:"n110" owner_id:"Dating of the Culm Limestone" id:"n111" owner_id:"Dating of the Non-Culm" id:"n112" owner_id:"Dating of the Non-Culm" id:"n113" owner_id:"Dating of the Non-Culm" id:"n114" owner_id:"Dating of the Non-Culm" id:"n115" owner_id:"Dating of the Non-Culm" id:"n116" owner_id:"Dating of the Non-Culm" id:"n117" owner_id:"Dating of the Non-Culm" id:"n118" owner_id:"Dating of the Non-Culm" id:"n119" owner_id:"Dating of the Non-Culm" id:"n12" owner_id:"Evidence" id:"n120" owner_id:"Dating of the Non-Culm" id:"n121" owner_id:"Dating of the Non-Culm" id:"n122" owner_id:"Dating of the Non-Culm" id:"n123" owner_id:"Dating of the Non-Culm" id:"n124" owner_id:"Dating of the Non-Culm" id:"n125" owner_id:"Dating of the Non-Culm" id:"n126" owner_id:"Dating of the Non-Culm" id:"n127" owner_id:"Dating of the Non-Culm" id:"n128" owner_id:"Dating of the Non-Culm" id:"n129" owner_id:"Dating of the Non-Culm" id:"n13" owner_id:"Evidence" id:"n130" owner_id:"Dating of the Non-Culm" id:"n131" owner_id:"Dating of the Non-Culm" id:"n132" owner_id:"Dating of the Non-Culm" id:"n133" owner_id:"Dating of the Non-Culm" id:"n134" owner_id:"Dating of the Non-Culm" id:"n135" owner_id:"Dating of the Non-Culm" id:"n136" owner_id:"Dating of the Non-Culm" id:"n137" owner_id:"Youngest Devonian Strata" id:"n138" owner_id:"Youngest Devonian Strata" id:"n139" owner_id:"Youngest Devonian Strata" id:"n14" owner_id:"Evidence" id:"n140" owner_id:"Youngest Devonian Strata" id:"n141" owner_id:"Youngest Devonian Strata" id:"n142" owner_id:"Youngest Devonian Strata" id:"n143" owner_id:"Youngest Devonian Strata" id:"n144" owner_id:"Youngest Devonian Strata" id:"n145" owner_id:"Youngest Devonian Strata" id:"n146" owner_id:"Youngest Devonian Strata" id:"n147" owner_id:"Youngest Devonian Strata" id:"n148" owner_id:"Youngest Devonian Strata" id:"n149" owner_id:"Youngest Devonian Strata" id:"n15" owner_id:"Rocks, Fossils and Time" id:"n150" owner_id:"Gap in the Sequence of Devonshi" id:"n151" owner_id:"Gap in the Sequence of Devonshi" id:"n152" owner_id:"Gap in the Sequence of Devonshi" id:"n153" owner_id:"Gap in the Sequence of Devonshi" id:"n154" owner_id:"Gap in the Sequence of Devonshi" id:"n155" owner_id:"Rocks, Fossils and Time" id:"n156" owner_id:"Rocks, Fossils and Time" id:"n157" owner_id:"Rocks, Fossils and Time" id:"n158" owner_id:"Rocks, Fossils and Time" id:"n159" owner_id:"Rocks, Fossils and Time" id:"n16" owner_id:"Evidence" id:"n160" owner_id:"Rocks, Fossils and Time" id:"n161" owner_id:"Rocks, Fossils and Time" id:"n162" owner_id:"Rocks, Fossils and Time" id:"n163" owner_id:"Rocks, Fossils and Time" id:"n164" owner_id:"Rocks, Fossils and Time" id:"n165" owner_id:"Rocks, Fossils and Time" id:"n166" owner_id:"Rocks, Fossils and Time" id:"n167" owner_id:"Old Red Sandstone Characteristi" id:"n168" owner_id:"Old Red Sandstone Characteristi" id:"n169" owner_id:"Old Red Sandstone Characteristi" id:"n17" owner_id:"Evidence" id:"n170" owner_id:"Old Red Sandstone Characteristi" id:"n171" owner_id:"Fossils in Pre-Old Red Sandston" id:"n172" owner_id:"Fossils in Pre-Old Red Sandston" id:"n173" owner_id:"Fossils in Pre-Old Red Sandston" id:"n174" owner_id:"Fossils in Pre-Old Red Sandston" id:"n175" owner_id:"Other Regions Than Devonshire" id:"n176" owner_id:"Other Regions Than Devonshire" id:"n177" owner_id:"Other Regions Than Devonshire" id:"n178" owner_id:"Other Regions Than Devonshire" id:"n179" owner_id:"Other Regions Than Devonshire" id:"n18" owner_id:"Evidence" id:"n180" owner_id:"Other Regions Than Devonshire" id:"n181" owner_id:"Other Regions Than Devonshire" id:"n182" owner_id:"Other Regions Than Devonshire" id:"n183" owner_id:"Other Regions Than Devonshire" id:"n184" owner_id:"Other Regions Than Devonshire" id:"n185" owner_id:"Other Regions Than Devonshire" id:"n186" owner_id:"Other Regions Than Devonshire" id:"n187" owner_id:"Other Regions Than Devonshire" id:"n188" owner_id:"Other Regions Than Devonshire" id:"n189" owner_id:"Dating of the Main Culm" id:"n19" owner_id:"Rocks, Fossils and Time" id:"n190" owner_id:"Dating of the Main Culm" id:"n191" owner_id:"Dating of the Main Culm" id:"n192" owner_id:"Dating of the Main Culm" id:"n193" owner_id:"Dating of the Main Culm" id:"n194" owner_id:"Dating of the Main Culm" id:"n195" owner_id:"Dating of the Main Culm" id:"n196" owner_id:"Dating of the Main Culm" id:"n197" owner_id:"Dating of the Main Culm" id:"n198" owner_id:"Dating of the Main Culm" id:"n199" owner_id:"Dating of the Main Culm" id:"n2" owner_id:"Evidence" id:"n20" owner_id:"Evidence" id:"n200" owner_id:"Dating of the Main Culm" id:"n201" owner_id:"Dating of the Main Culm" id:"n202" owner_id:"Dating of the Main Culm" id:"n203" owner_id:"Dating of the Main Culm" id:"n204" owner_id:"Dating of the Main Culm" id:"n205" owner_id:"Dating of the Main Culm" id:"n206" owner_id:"Dating of the Main Culm" id:"n207" owner_id:"Dating of the Main Culm" id:"n208" owner_id:"Dating of the Culm Limestone" id:"n209" owner_id:"Dating of the Culm Limestone" id:"n21" owner_id:"Fossils in Pre-Old Red Sandston" id:"n210" owner_id:"Dating of the Culm Limestone" id:"n211" owner_id:"Dating of the Culm Limestone" id:"n212" owner_id:"Dating of the Culm Limestone" id:"n213" owner_id:"Dating of the Culm Limestone" id:"n214" owner_id:"Dating of the Culm Limestone" id:"n215" owner_id:"Dating of the Culm Limestone" id:"n216" owner_id:"Dating of the Culm Limestone" id:"n217" owner_id:"Dating of the Culm Limestone" id:"n218" owner_id:"Dating of the Culm Limestone" id:"n219" owner_id:"Dating of the Culm Limestone" id:"n22" owner_id:"Evidence" id:"n220" owner_id:"Dating of the Culm Limestone" id:"n221" owner_id:"Dating of the Culm Limestone" id:"n222" owner_id:"Dating of the Culm Limestone" id:"n223" owner_id:"Dating of the Culm Limestone" id:"n224" owner_id:"Dating of the Culm Limestone" id:"n225" owner_id:"Dating of the Non-Culm" id:"n226" owner_id:"Dating of the Non-Culm" id:"n227" owner_id:"Dating of the Non-Culm" id:"n228" owner_id:"Dating of the Non-Culm" id:"n229" owner_id:"Dating of the Non-Culm" id:"n23" owner_id:"Evidence" id:"n230" owner_id:"Dating of the Non-Culm" id:"n231" owner_id:"Dating of the Non-Culm" id:"n232" owner_id:"Dating of the Non-Culm" id:"n233" owner_id:"Dating of the Non-Culm" id:"n234" owner_id:"Dating of the Non-Culm" id:"n235" owner_id:"Dating of the Non-Culm" id:"n236" owner_id:"Dating of the Non-Culm" id:"n237" owner_id:"Dating of the Non-Culm" id:"n238" owner_id:"Dating of the Non-Culm" id:"n239" owner_id:"Dating of the Non-Culm" id:"n24" owner_id:"Evidence" id:"n240" owner_id:"Dating of the Non-Culm" id:"n241" owner_id:"Dating of the Non-Culm" id:"n242" owner_id:"Dating of the Non-Culm" id:"n243" owner_id:"Dating of the Non-Culm" id:"n244" owner_id:"Dating of the Non-Culm" id:"n245" owner_id:"Dating of the Non-Culm" id:"n246" owner_id:"Dating of the Non-Culm" id:"n247" owner_id:"Dating of the Non-Culm" id:"n248" owner_id:"Dating of the Non-Culm" id:"n249" owner_id:"Youngest Devonian Strata" id:"n25" owner_id:"Evidence" id:"n250" owner_id:"Youngest Devonian Strata" id:"n251" owner_id:"Youngest Devonian Strata" id:"n252" owner_id:"Youngest Devonian Strata" id:"n253" owner_id:"Youngest Devonian Strata" id:"n254" owner_id:"Youngest Devonian Strata" id:"n255" owner_id:"Youngest Devonian Strata" id:"n256" owner_id:"Youngest Devonian Strata" id:"n257" owner_id:"Youngest Devonian Strata" id:"n258" owner_id:"Youngest Devonian Strata" id:"n259" owner_id:"Youngest Devonian Strata" id:"n26" owner_id:"Evidence" id:"n260" owner_id:"Youngest Devonian Strata" id:"n261" owner_id:"Youngest Devonian Strata" id:"n262" owner_id:"Youngest Devonian Strata" id:"n263" owner_id:"Youngest Devonian Strata" id:"n264" owner_id:"Youngest Devonian Strata" id:"n265" owner_id:"Youngest Devonian Strata" id:"n266" owner_id:"Youngest Devonian Strata" id:"n267" owner_id:"Youngest Devonian Strata" id:"n268" owner_id:"Youngest Devonian Strata" id:"n269" owner_id:"Youngest Devonian Strata" id:"n27" owner_id:"Evidence" id:"n270" owner_id:"Youngest Devonian Strata" id:"n271" owner_id:"Youngest Devonian Strata" id:"n272" owner_id:"Youngest Devonian Strata" id:"n273" owner_id:"Youngest Devonian Strata" id:"n274" owner_id:"Youngest Devonian Strata" id:"n275" owner_id:"Youngest Devonian Strata" id:"n276" owner_id:"Youngest Devonian Strata" id:"n277" owner_id:"Youngest Devonian Strata" id:"n278" owner_id:"Youngest Devonian Strata" id:"n279" owner_id:"Youngest Devonian Strata" id:"n28" owner_id:"Dating of the Non-Culm" id:"n280" owner_id:"Youngest Devonian Strata" id:"n281" owner_id:"Youngest Devonian Strata" id:"n282" owner_id:"Youngest Devonian Strata" id:"n283" owner_id:"Youngest Devonian Strata" id:"n284" owner_id:"Youngest Devonian Strata" id:"n285" owner_id:"Youngest Devonian Strata" id:"n286" owner_id:"Youngest Devonian Strata" id:"n287" owner_id:"Youngest Devonian Strata" id:"n288" owner_id:"Youngest Devonian Strata" id:"n289" owner_id:"Youngest Devonian Strata" id:"n29" owner_id:"Dating of the Non-Culm" id:"n290" owner_id:"Youngest Devonian Strata" id:"n291" owner_id:"Youngest Devonian Strata" id:"n292" owner_id:"Youngest Devonian Strata" id:"n293" owner_id:"Youngest Devonian Strata" id:"n294" owner_id:"Youngest Devonian Strata" id:"n295" owner_id:"Youngest Devonian Strata" id:"n296" owner_id:"Youngest Devonian Strata" id:"n297" owner_id:"Gap in the Sequence of Devonshi" id:"n298" owner_id:"Gap in the Sequence of Devonshi" id:"n299" owner_id:"Gap in the Sequence of Devonshi" id:"n3" owner_id:"Evidence" id:"n30" owner_id:"Evidence" id:"n300" owner_id:"Gap in the Sequence of Devonshi" id:"n301" owner_id:"Gap in the Sequence of Devonshi" id:"n302" owner_id:"Gap in the Sequence of Devonshi" id:"n303" owner_id:"Gap in the Sequence of Devonshi" id:"n304" owner_id:"Gap in the Sequence of Devonshi" id:"n305" owner_id:"Gap in the Sequence of Devonshi" id:"n306" owner_id:"Gap in the Sequence of Devonshi" id:"n307" owner_id:"Gap in the Sequence of Devonshi" id:"n308" owner_id:"Gap in the Sequence of Devonshi" id:"n309" owner_id:"Gap in the Sequence of Devonshi" id:"n31" owner_id:"Rocks, Fossils and Time" id:"n310" owner_id:"Gap in the Sequence of Devonshi" id:"n311" owner_id:"Gap in the Sequence of Devonshi" id:"n312" owner_id:"Gap in the Sequence of Devonshi" id:"n313" owner_id:"Gap in the Sequence of Devonshi" id:"n314" owner_id:"Gap in the Sequence of Devonshi" id:"n315" owner_id:"Gap in the Sequence of Devonshi" id:"n316" owner_id:"Gap in the Sequence of Devonshi" id:"n317" owner_id:"Gap in the Sequence of Devonshi" id:"n318" owner_id:"Gap in the Sequence of Devonshi" id:"n319" owner_id:"Gap in the Sequence of Devonshi" id:"n32" owner_id:"Rocks, Fossils and Time" id:"n320" owner_id:"Gap in the Sequence of Devonshi" id:"n321" owner_id:"Gap in the Sequence of Devonshi" id:"n322" owner_id:"Gap in the Sequence of Devonshi" id:"n323" owner_id:"Gap in the Sequence of Devonshi" id:"n324" owner_id:"Gap in the Sequence of Devonshi" id:"n325" owner_id:"Gap in the Sequence of Devonshi" id:"n326" owner_id:"Gap in the Sequence of Devonshi" id:"n327" owner_id:"Gap in the Sequence of Devonshi" id:"n328" owner_id:"Gap in the Sequence of Devonshi" id:"n329" owner_id:"Gap in the Sequence of Devonshi" id:"n33" owner_id:"Rocks, Fossils and Time" id:"n330" owner_id:"Gap in the Sequence of Devonshi" id:"n331" owner_id:"Gap in the Sequence of Devonshi" id:"n332" owner_id:"Gap in the Sequence of Devonshi" id:"n333" owner_id:"Gap in the Sequence of Devonshi" id:"n334" owner_id:"Gap in the Sequence of Devonshi" id:"n34" owner_id:"Rocks, Fossils and Time" id:"n35" owner_id:"Rocks, Fossils and Time" id:"n36" owner_id:"Rocks, Fossils and Time" id:"n37" owner_id:"Rocks, Fossils and Time" id:"n38" owner_id:"Rocks, Fossils and Time" id:"n39" owner_id:"Dating of the Main Culm" id:"n4" owner_id:"Evidence" id:"n40" owner_id:"Old Red Sandstone Characteristi" id:"n41" owner_id:"Rocks, Fossils and Time" id:"n42" owner_id:"Rocks, Fossils and Time" id:"n43" owner_id:"Rocks, Fossils and Time" id:"n44" owner_id:"Rocks, Fossils and Time" id:"n45" owner_id:"Old Red Sandstone Characteristi" id:"n46" owner_id:"Old Red Sandstone Characteristi" id:"n47" owner_id:"Rocks, Fossils and Time" id:"n48" owner_id:"Rocks, Fossils and Time" id:"n49" owner_id:"Rocks, Fossils and Time" id:"n5" owner_id:"Evidence" id:"n50" owner_id:"Rocks, Fossils and Time" id:"n51" owner_id:"Rocks, Fossils and Time" id:"n52" owner_id:"Rocks, Fossils and Time" id:"n53" owner_id:"Old Red Sandstone Characteristi" id:"n54" owner_id:"Rocks, Fossils and Time" id:"n55" owner_id:"Rocks, Fossils and Time" id:"n56" owner_id:"Rocks, Fossils and Time" id:"n57" owner_id:"Rocks, Fossils and Time" id:"n58" owner_id:"Old Red Sandstone Characteristi" id:"n59" owner_id:"Old Red Sandstone Characteristi" id:"n6" owner_id:"Evidence" id:"n60" owner_id:"Old Red Sandstone Characteristi" id:"n61" owner_id:"Old Red Sandstone Characteristi" id:"n62" owner_id:"Old Red Sandstone Characteristi" id:"n63" owner_id:"Old Red Sandstone Characteristi" id:"n64" owner_id:"Youngest Devonian Strata" id:"n65" owner_id:"Fossils in Pre-Old Red Sandston" id:"n66" owner_id:"Youngest Devonian Strata" id:"n67" owner_id:"Other Regions Than Devonshire" id:"n68" owner_id:"Other Regions Than Devonshire" id:"n69" owner_id:"Other Regions Than Devonshire" id:"n7" owner_id:"Evidence" id:"n70" owner_id:"Other Regions Than Devonshire" id:"n71" owner_id:"Other Regions Than Devonshire" id:"n72" owner_id:"Other Regions Than Devonshire" id:"n73" owner_id:"Other Regions Than Devonshire" id:"n74" owner_id:"Other Regions Than Devonshire" id:"n75" owner_id:"Other Regions Than Devonshire" id:"n76" owner_id:"Dating of the Main Culm" id:"n77" owner_id:"Dating of the Main Culm" id:"n78" owner_id:"Dating of the Main Culm" id:"n79" owner_id:"Dating of the Main Culm" id:"n8" owner_id:"Evidence" id:"n80" owner_id:"Dating of the Main Culm" id:"n81" owner_id:"Dating of the Main Culm" id:"n82" owner_id:"Dating of the Main Culm" id:"n83" owner_id:"Dating of the Main Culm" id:"n84" owner_id:"Dating of the Main Culm" id:"n85" owner_id:"Dating of the Main Culm" id:"n86" owner_id:"Dating of the Main Culm" id:"n87" owner_id:"Dating of the Main Culm" id:"n88" owner_id:"Dating of the Main Culm" id:"n89" owner_id:"Dating of the Main Culm" id:"n9" owner_id:"Evidence" id:"n90" owner_id:"Dating of the Non-Culm" id:"n91" owner_id:"Dating of the Non-Culm" id:"n92" owner_id:"Dating of the Non-Culm" id:"n93" owner_id:"Dating of the Main Culm" id:"n94" owner_id:"Dating of the Culm Limestone" id:"n95" owner_id:"Dating of the Culm Limestone" id:"n96" owner_id:"Dating of the Culm Limestone" id:"n97" owner_id:"Dating of the Culm Limestone" id:"n98" owner_id:"Dating of the Culm Limestone" id:"n99" owner_id:"Dating of the Culm Limestone" Remaining unparsed input: ' ' ```

You can tweak the semantics by looking at https://github.com/sehe/spirit-graphviz/blob/master/spirit-graphviz.hpp#L559

        } else {
            if (&owner != it->owner)
                debug << "Reassigning node " << id
                      << (it->owner ? " from graph '" + it->owner->id + "'"
                                    : "")
                      << " to graph '" << owner.id << "'\n";
        }

        all_nodes.modify(it, [&owner](OwnedNode& on) { /*if (not on.owner)*/ on.owner = &owner; });

Changing it to read something more like:

        } else {
            if (&owner != it->owner)
                debug << "Not reassigning node " << id
                      << (it->owner ? " from graph '" + it->owner->id + "'" : "")
                      << " to graph '" << owner.id << "'\n";
        }

        all_nodes.modify(it, [&owner](OwnedNode& on) { if (not on.owner) on.owner = &owner; });

Keep in mind that YMMV. I feel it makes a lot of sense to retain initial node ownership (as evidenced by the existence of the commented if (not on.owner) condition), but it might prove harder to roundtrip/achieve parity with graphviz's native semantics. If that's not important for your use-case, by all means tweak to taste :)

didibib commented 1 year ago

In order for me to be able to print these lines lines id:"n0" owner_id:"G"... I had to run it in Release mode, but the code block at https://github.com/sehe/spirit-graphviz/blob/3590f8500dbca93fb307e97dfb433a8514c667f2/spirit-graphviz.hpp#L179 would be grayed out and then I would get the error C2679 binary '<<': no operator found which takes a right-hand operand of type 'T' (or there is no acceptable conversion)boost\fusion\sequence\io\detail\out.hpp 62

In the build output it said that the error was generated by this line spirit-graphviz.hpp(243,111): message : see reference to function template instantiation.

I just removed the guards, but maybe this information is useful for you.

I out-commented the if (not on.owner) condition, because that is indeed the behavior I needed.

Thanks for your help!

sehe commented 1 year ago

Yeah the AST printing code was originally only intended for debugging. With BOOST_SPIRIT_DEBUG, mind you, not using a debugger.

Glad you found the code useful, good luck!