From: Ian Jackson Date: Tue, 26 Feb 2019 10:27:34 +0000 (+0000) Subject: delete obsolete dual-based stuff X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=2d25ee95dc99e9be31833127606dfa4941bb84d9;p=pandemic-rising-tide.git delete obsolete dual-based stuff planar-graph does this now --- diff --git a/parse-input-graph b/parse-input-graph index a4c46d4..f3d81d0 100755 --- a/parse-input-graph +++ b/parse-input-graph @@ -15,22 +15,12 @@ our %region; # $region{NAME}{Adj}[]{Regexp} # $region{NAME}{Adj}[]{Dikes} # $region{NAME}{Adj}[]{L} -# %region{NAME}{Adj}[]{Vertices}[0..1] // computed by dual our %adj; # $adj{EARLIER}{LATER}{Dikes} # $adj{EARLIER}{LATER}{L}[] # $adj{EARLIER}{LATER}{T}[] -# computed by dual() -our @vertex; -# $vertex[]{Text} -# $vertex[]{EdgeIds}[] -# $vertex[]{Edges}[]{Regions}[0..1] = NAME -# $vertex[]{Edges}[]{VIB} -# $vertex[]{Edges}[]{EdgeId} -# $vertex[]{Edges}[]{Outside} - sub read_in () { my $ccolour; my $cregion; @@ -166,100 +156,6 @@ sub edge_id_to_other_id ($$) { confess "$ra $adjia ?"; } -sub dual () { - # We want to turn the graph from a graph on the regions, to - # one where the nodes are the vertices of region boundaries. - # - # Each adjacency in %adj has two ends, each of which is at - # such a vertex. We need to identify which of these vertices - # are the same. We do this by assigning an id to each vertex. - # - # This is actually a DJF, where the to-be-vertices are the connected - # components, and the edges indicate that two vertices are the same. - - my $g = Graph::Undirected->new(unionfind => 1); - - # vertex " # " is the vertex at the - # anticlockwise end of the i'th listed edge of Region Name. - - foreach my $ra (sort keys %region) { - my $adjsa = $region{$ra}{Adj}; - foreach my $adjia (0..$#$adjsa) { - my ($rb, $adjib) = edge_id_to_other_id($ra, $adjia); - my $adjsb = $region{$rb}{Adj}; - my $adjibc = ($adjib + 1) % @$adjsb; - my $adja = $adjsa->[$adjia]; - my $va = "$ra # $adjia"; - # $va is the vertex at the anticlockwise end - # of edge no.$adjia of region $ra - my $ra_outside = ($ra eq 'L' or $ra eq 'NZ'); - my $rb_outside = ($rb eq 'L' or $rb eq 'NZ'); - next if $ra_outside and $rb_outside; - # $rb is the region on the other side of that edge - my $vb = "$rb # $adjibc"; - # $vb is the vertex at the *clockwise* end - # of that same edge, which is edge no.$adjibc of region $rb - print STDERR "vertex $va = $vb\n"; - $g->add_edge($va,$vb); - } - } - my %edgeid2vi; - # $edgeid2vi{EDGEID} = VI s.t. some $vertex[VI]{EdgeIds}[][J] eq EDGEID - my $cci = 0; - foreach my $cc ($g->connected_components) { - print STDERR "CC $cci:\n"; $cci++; - print STDERR " $_\n" foreach @$cc; - my %uniq; - foreach my $e (@$cc) { - $e =~ m/ \# \d+$/ or confess; - push @{ $uniq{$`} }, $e; - } - foreach my $u (values %uniq) { - next if @$u == 1; - my ($x,$y) = @$u or confess; - my @p = $g->SP_Dijkstra($x, $y); - confess join ' -- ', @p; - } - - my $vertex = { - EdgeIds => $cc, - Text => (join "\n", @$cc), - }; - foreach my $e (@$cc) { - $edgeid2vi{$e} = scalar @vertex; - } - push @vertex, $vertex; - } - foreach my $via (0..$#vertex) { - my $vertexa = $vertex[$via]; - $vertexa->{Edges} = []; - foreach my $eid (@{ $vertexa->{EdgeIds} }) { - $eid =~ m/ # (\d+)$/ or confess; - my ($ra, $adjia) = ($`, $1); - my $adjsa = $region{$ra}{Adj}; - - my ($ro,$adjio) = edge_id_to_other_id($ra,$adjia); - my $ra_out = ($ra eq 'L' or $ra eq 'NZ'); - my $ro_out = ($ro eq 'L' or $ro eq 'NZ'); - my $is_spec = ($ra_out or $ro_out); - my $adjib = ($adjia + 1) % @$adjsa; - my $vib = $edgeid2vi{"$ra # $adjib"}; - - print STDERR "VIA=$via | $ra # $adjia | # $adjib VIB=$vib\n"; - my $vertexb = $vertex[$vib]; - confess "# $adjib $vib" unless defined $vib and defined $vertexb; - my $einfo = { - VIB => $vib, - EdgeId => $eid, - Text => "$eid\n$ro # $adjio", - Spec => $is_spec, - Outside => $ro_out, - }; - push @{ $vertexa->{Edges} }, $einfo; - } - } -} - sub o { print @_ or die $!; } sub plag_prs ($) { @@ -270,12 +166,6 @@ sub plag_prs ($) { return "$t"; } -sub plag_prv ($) { - my ($vi) = @_; - my $t = $vertex[$vi]{Text}; - plag_prs($t); -} - sub output_planar_graph () { foreach my $ra (sort keys %region) { o(plag_prs($ra), "\n"); @@ -289,48 +179,9 @@ sub output_planar_graph () { } -sub output_dot () { - o <{Text}."\"];\n"); - foreach my $ei (@{ $vertexa->{Edges} }) { - my $vib = $ei->{VIB}; - next unless $via <= $vib; - #if ($r1 eq 'NZ' || $r1 eq 'L') { - # $r1n = "_$r1 $r0"; - # next; - #} - #next if $ei->{Spec}; - o "\"$via\" -- \"$vib\" ["; - o " weight=0.00001, w=0.00001, len=5," if $ei->{Spec}; - o "fontsize=8, label=\"". - $ei->{Text}."\","; - o "];\n"; - } - } - o "}\n"; -} - read_in(); resolve_arefs(); adjacencies(); -#dual(); -#output_dot(); output_planar_graph(); # Local variables: