view release on metacpan or search on metacpan
lib/Graph/Easy/Introspect.pm view on Meta::CPAN
# or terminates one (prev cell is VER/HOR).
# Introducing corner: assign wp[ci]->wp[ci+1], then advance ci.
# Terminating corner: advance ci first, then assign wp[ci]->wp[ci+1].
# VER/HOR cells: always assign wp[ci]->wp[ci+1], never advance ci.
#
# This gives contiguous, directed segments: each cell's endpoint equals
# the next cell's start point.
my %is_straight_type = (VER => 1, HOR => 1, CROSS => 1, HOLE => 1) ;
my ($fp_lx, $fp_ly) = (0, 0) ;
view all matches for this distribution
view release on metacpan or search on metacpan
doc/manual/a-star.html view on Meta::CPAN
what happens if you have two nodes, each with 20 ports...
</p>
<p>
One of the strengths of the general A* algorithm is that it supports with ease
multiple start- and endpoints.
</p>
<h4>Multiple Startpoints</h4>
<p>
doc/manual/a-star.html view on Meta::CPAN
<p>
In the example above, the algorithm would explore both equally likely paths at the
same time, choosing the one that hits (arbitrarily) one end port first.
<br>
With the tie-breaker, it will follow only one of the paths (f.i. East, then South),
until it either hits the endpoint, or finds an obstacle.
</p>
<h4>Multiple Endpoints</h4>
<p>
Multiple endpoints are easily implemented, too. Instead of stopping the algorithm
when we hit <i>the</i> endpoint, we watch for all of them simultanously.
<br>
In addition, instead of calculating the distance from the current node to the
endpoint, we calculate the distance to each endpoint, and then use the smallest
one.
</p>
<p>
Thus the algorithm will automatically gravitate towards the nearest port, but
doc/manual/a-star.html view on Meta::CPAN
<a name="terminating"></a>
<h4>Stopping</h4>
<p>
The algorithm will stop when it reaches one of the possible endpoints. However, if
the path to the goal is blocked on all sides, it will run into trouble. The reason
is that our layout plane is essential infinitely big, and the algorithm would
spiral outwards and out of control, never finishing.
</p>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graph/Easy/Layout/Scout.pm view on Meta::CPAN
EDGE_START_N() => EDGE_END_N(),
};
sub _end_points
{
# modify last field of path to be the correct endpoint; and the first field
# to be the correct startpoint:
my ($self, $edge, $coords, $dx, $dy) = @_;
return $coords if $edge->undirected();
lib/Graph/Easy/Layout/Scout.pm view on Meta::CPAN
EDGE_END_N,
EDGE_END_E,
EDGE_END_S,
];
# if the target/source node is of shape "edge", remove the endpoint
if ( ($edge->{to}->attribute('shape')) eq 'edge')
{
$end_flags = [ 0,0,0,0 ];
}
if ( ($edge->{from}->attribute('shape')) eq 'edge')
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graph/Fast.pm view on Meta::CPAN
delete($self->{vertices}->{$from}->{edges_out}->{$to});
# now search it in the destination vertex' list, delete it there
# also only delete the first matching one here (though now there
# shouldn't be any duplicates at all because now we're matching the
# actual edge, not just its endpoints like above.
delete($self->{vertices}->{$to}->{edges_in}->{$from});
# and remove it from the graph's vertex list
@{$self->{edges}} = grep { $_ != $e } @{$self->{edges}}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graph/Layout/Aesthetic/Force.pm view on Meta::CPAN
Nodes repel each other with a force 1/d
=item L<Graph::Layout::Aesthetic::Force::NodeEdgeRepulsion|Graph::Layout::Aesthetic::Force::NodeEdgeRepulsion>
Nodes repel from the nearest point on the line through an edge
if that point is between the endpoints of the edge. Magnitude 1/d.
=item L<Graph::Layout::Aesthetic::Force::MinEdgeIntersect|Graph::Layout::Aesthetic::Force::MinEdgeIntersect>
Crossed edge midpoints repel each other with a constant magnitude of 1.
Only works in 2 dimensions.
view all matches for this distribution
view release on metacpan or search on metacpan
devel/lib/MyPlanar.pm view on Meta::CPAN
}
foreach my $a ($p1,$p2) {
foreach my $b ($p3,$p4) {
if ($a->[0]==$b->[0] && $a->[1]==$b->[1]) {
### endpoint in common ...
return [$a,$a];
}
}
}
devel/lib/MyPlanar.pm view on Meta::CPAN
my ($p1,$p2, $p3,$p4) = @$points;
# DistanceToSegment() is +ve on the left and -ve on the right.
# Here want absolute value.
#
# Shortest distance is always attained going to the endpoint of one
# segment, since straight lines.
my $ret;
foreach (0,1) {
foreach my $i (2,3) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graph/Matching.pm view on Meta::CPAN
#
# Vertices are numbered 0 .. ($nvertex-1).
# Non-trivial blossoms are numbered nvertex .. (2*$nvertex-1)
#
# Edges are numbered 0 .. ($nedge-1).
# Edge endpoints are numbered 0 .. (2*$nedge-1), such that endpoints
# (2*k) and (2*k+1) both belong to the edge with index k.
#
# Many terms used in the comments come from the paper by Galil.
# You will probably need the paper to make sense of this code.
#
lib/Graph/Matching.pm view on Meta::CPAN
$maxweight = $wt if ($wt > $maxweight);
$all_integer_weights = $all_integer_weights && ($wt == int($wt));
}
my $nvertex = $#nodelist + 1;
# If $p is an endpoint index,
# $endpoint[$p] is the vertex index to which endpoint $p is attached.
my @endpoint;
$#endpoint = 2*$nedge-1;
for (my $k = $nedge - 1; $k >= 0; $k--) {
$endpoint[2*$k] = $nodemap{$graph->[$k]->[0]};
$endpoint[2*$k+1] = $nodemap{$graph->[$k]->[1]};
}
# If $v is a vertex index,
# $neighbend[$v] refers to an array of remote endpoints attached to $v.
my @neighbend;
$#neighbend = $nvertex-1;
for (my $k = $nedge - 1; $k >= 0; $k--) {
my $v = $endpoint[2*$k];
my $w = $endpoint[2*$k+1];
assert($v != $w);
push @{$neighbend[$v]}, 2*$k + 1;
push @{$neighbend[$w]}, 2*$k;
}
# If $v is a vertex index,
# $mate[$v] is the remote endpoint of its matched edge, or -1 if $v
# is single. (i.e. $endpoint[$mate[$v]] is $v's partner vertex)
# Initially all vertices are single.
my @mate = ( -1 ) x $nvertex;
# If $b is a top-level blossom,
# $label[$b] is 0 if $b is unlabeled (free);
lib/Graph/Matching.pm view on Meta::CPAN
# $label[$v] is 2 iff $v is reachable from an S-vertex outside the blossom.
# Labels are assigned during a stage and reset after each augmentation.
my @label = ( 0 ) x (2*$nvertex);
# If $b is a labeled top-level blossom,
# $labelend[$b] is the remote endpoint of the edge through which b obtained
# its label, or -1 if $b's base vertex is single.
# If $v is a vertex inside a T-blossom and $label[$v] == 2,
# $labelend[$v] is the remote endpoint of the edge through which $v is
# reachable from outside the blossom.
my @labelend = ( undef ) x (2*$nvertex);
# If $v is a vertex,
# $inblossom[$v] is the top-level blossom to which $v belongs.
lib/Graph/Matching.pm view on Meta::CPAN
# If $b is a (sub-)blossom,
# $blossombase[$b] is its base VERTEX (i.e. recursive sub-blossom).\
my @blossombase = ( 0 .. ($nvertex-1), ( undef ) x $nvertex );
# If $b is a non-trivial (sub-)blossom,
# $blossomendps[$b] refers to an array of endpoints on its connecting
# edges, such that $blossomendps[$b]->[$i] is the local endpoint of
# $blossomchilds[$b]->[$i] on the edge that connects it to
# $blossomchilds[$b]->[wrap($i+1)].
my @blossomendps = ( undef ) x (2*$nvertex);
# If $v is a free vertex (or an unreached vertex inside a T-blossom),
# $bestedge[$v] is the remote endpoint on a least-slack edge to an S-vertex
# or -1 if there is no such edge.
# If $b is a (possibly trivial) top-level S-blossom,
# $bestedge[$b] is the remote endpoint on a least-slack edge to a
# different S-blossom, or -1 if there is no such edge.
# This is used for efficient computation of delta2 and delta3.
my @bestedge = ( -1 ) x (2*$nvertex);
# If $b is a non-trivial top-level S-blossom,
# $blossombestedges[$b] refers to an array of remote endpoints on
# least-slack edges to neighbouring S-blossoms, or is undef() if no
# such list has been computed yet.
# This is used for efficient computation of delta3.
my @blossombestedges = ( undef ) x (2*$nvertex);
lib/Graph/Matching.pm view on Meta::CPAN
# slack($k)
# returns 2 * slack of edge $k (does not work inside blossoms).
local *slack = sub {
my ($k) = @_;
my $v = $endpoint[2*$k];
my $w = $endpoint[2*$k+1];
my $weight = $graph->[$k]->[2];
return $dualvar[$v] + $dualvar[$w] - 2 * $weight;
};
# blossomleaves($b)
lib/Graph/Matching.pm view on Meta::CPAN
};
# assignlabel($w, $t, $p)
# assigns label $t to the top-level blossom containing vertex $w
# and record the fact that $w was reached through the edge with
# remote endpoint $p.
local *assignlabel = sub {
my ($w, $t, $p) = @_;
DBG("assignlabel($w,$t,$p)") if ($DBG);
my $b = $inblossom[$w];
assert($label[$w] == 0 && $label[$b] == 0);
lib/Graph/Matching.pm view on Meta::CPAN
# $b became a T-blossom; assign label S to its mate.
# (If b is a non-trivial blossom, its base is the only vertex
# with an external mate.)
my $base = $blossombase[$b];
assert($mate[$base] >= 0);
assignlabel($endpoint[$mate[$base]], 1, $mate[$base] ^ 1);
}
};
# scanblossom($v, $w)
# traces back from vertices $v and $w to discover either a new blossom
lib/Graph/Matching.pm view on Meta::CPAN
assert($labelend[$b] == $mate[$blossombase[$b]]);
if ($labelend[$b] == -1) {
# The base of blossom $b is single; stop tracing this path.
$v = -1;
} else {
$v = $endpoint[$labelend[$b]];
$b = $inblossom[$v];
# $b is a T-blossom; trace one more step back.
assert($label[$b] == 2);
assert($labelend[$b] >= 0);
$v = $endpoint[$labelend[$b]];
}
# Swap v and w so that we alternate between both paths.
if ($w != -1) {
my $t = $v;
$v = $w;
lib/Graph/Matching.pm view on Meta::CPAN
# constructs a new blossom with given base, containing edge $k which
# connects a pair of S vertices; labels the new blossom as S; sets its dual
# variable to zero; relabels its T-vertices to S and adds them to the queue.
local *addblossom = sub {
my ($base, $k) = @_;
my $v = $endpoint[2*$k];
my $w = $endpoint[2*$k+1];
my $bb = $inblossom[$base];
my $bv = $inblossom[$v];
my $bw = $inblossom[$w];
# Create blossom.
my $b = pop(@unusedblossoms);
DBG("addblossom($base,$k) v=$v w=$w -> b=$b") if ($DBG);
$blossombase[$b] = $base;
$blossomparent[$b] = -1;
$blossomparent[$bb] = $b;
# Build lists of sub-blossoms and their interconnecting edge endpoints.
my @path;
my @endps;
# Trace back from $v to $base.
while ($bv != $bb) {
# Add $bv to the new blossom.
lib/Graph/Matching.pm view on Meta::CPAN
unshift @path, $bv;
unshift @endps, $labelend[$bv];
# Trace one step back.
assert($label[$bv] == 2 || ($label[$bv] == 1 && $labelend[$bv] == $mate[$blossombase[$bv]]));
assert($labelend[$bv] >= 0);
$v = $endpoint[$labelend[$bv]];
$bv = $inblossom[$v];
}
# Add the base sub-blossom;
# add the edge that connects the pair of S vertices.
unshift @path, $bb;
lib/Graph/Matching.pm view on Meta::CPAN
push @path, $bw;
push @endps, ($labelend[$bw] ^ 1);
# Trace one step back.
assert($label[$bw] == 2 || ($label[$bw] == 1 && $labelend[$bw] == $mate[$blossombase[$bw]]));
assert($labelend[$bw] >= 0);
$w = $endpoint[$labelend[$bw]];
$bw = $inblossom[$w];
}
$blossomchilds[$b] = \@path;
$blossomendps[$b] = \@endps;
# Set new blossom's label to S.
lib/Graph/Matching.pm view on Meta::CPAN
if (!defined($blossombestedges[$bv])) {
# This subblossom does not have a list of least-slack edges;
# get the information from the vertices.
foreach (blossomleaves($bv)) {
foreach my $p (@{$neighbend[$_]}) {
my $j = $endpoint[$p];
my $bj = $inblossom[$j];
if ($bj != $b && $label[$bj] == 1 &&
($bestedgeto[$bj] == -1 ||
slack($p>>1) < slack($bestedgeto[$bj]>>1))) {
$bestedgeto[$bj] = $p;
lib/Graph/Matching.pm view on Meta::CPAN
}
}
} else {
# Walk this subblossom's least-slack edges.
foreach my $p (@{$blossombestedges[$bv]}) {
my $j = $endpoint[$p];
my $bj = $inblossom[$j];
if ($bj != $b && $label[$bj] == 1 &&
($bestedgeto[$bj] == -1 ||
slack($p>>1) < slack($bestedgeto[$bj]>>1))) {
$bestedgeto[$bj] = $p;
lib/Graph/Matching.pm view on Meta::CPAN
slack($p>>1) < slack($bestedge[$b]>>1)) {
$bestedge[$b] = $p;
}
}
DBG("blossomchilds[$b] = ", join(',', @path)) if ($DBG);
DBG("blossomendps[$b] = ", join('; ', map { $endpoint[$_] . "," . $endpoint[$_^1] } @{$blossomendps[$b]})) if ($DBG);
};
# expandblossom($b, $endstage)
# expands the given top-level blossom.
local *expandblossom = sub {
lib/Graph/Matching.pm view on Meta::CPAN
# blossom obtained its label, and relabel sub-blossoms until
# we reach the base.
# Figure out through which sub-blossom the expanding blossom
# obtained its label initially.
assert($labelend[$b] >= 0);
my $entrychild = $inblossom[$endpoint[$labelend[$b] ^ 1]];
# Decide in which direction we will go round the blossom.
my $j = 0;
my $jstep;
$j++ until ($blossomchilds[$b]->[$j] == $entrychild);
if ($j & 1) {
lib/Graph/Matching.pm view on Meta::CPAN
my $p = $labelend[$b];
while ($j != 0) {
# Relabel the T-sub-blossom.
my $q = ($jstep == 1) ? ($blossomendps[$b]->[$j]) :
($blossomendps[$b]->[$j-1]^1);
$label[$endpoint[$p^1]] = 0;
$label[$endpoint[$q^1]] = 0;
assignlabel($endpoint[$p^1], 2, $p);
# Step to the next S-sub-blossom and note its forward endpoint.
$allowedge[$q>>1] = 1;
$j += $jstep;
$p = ($jstep == 1) ? ($blossomendps[$b]->[$j]) :
($blossomendps[$b]->[$j-1]^1);
# Step to the next T-sub-blossom.
lib/Graph/Matching.pm view on Meta::CPAN
$j += $jstep;
}
# Relabel the base T-sub-blossom WITHOUT stepping through to
# its mate (so don't call assignlabel).
my $bv = $blossomchilds[$b]->[$j];
$label[$endpoint[$p^1]] = 2;
$label[$bv] = 2;
$labelend[$endpoint[$p^1]] = $p;
$labelend[$bv] = $p;
$bestedge[$bv] = -1;
# Continue along the blossom until we get back to entrychild.
$j += $jstep;
while ($blossomchilds[$b]->[$j] != $entrychild) {
lib/Graph/Matching.pm view on Meta::CPAN
# label T to the sub-blossom.
if (defined($v)) {
assert($label[$v] == 2);
assert($inblossom[$v] == $bv);
$label[$v] = 0;
$label[$endpoint[$mate[$blossombase[$bv]]]] = 0;
assignlabel($v, 2, $labelend[$v]);
}
$j += $jstep;
}
}
lib/Graph/Matching.pm view on Meta::CPAN
# Step to the next sub-blossom and augment it recursively.
$j += $jstep;
$t = $blossomchilds[$b]->[$j];
my $p = ($jstep == 1) ? ($blossomendps[$b]->[$j]) :
($blossomendps[$b]->[$j-1]^1);
augmentblossom($t, $endpoint[$p]) if ($t >= $nvertex);
# Step to the next sub-blossom and augment it recursively.
$j += $jstep;
$t = $blossomchilds[$b]->[$j];
augmentblossom($t, $endpoint[$p^1]) if ($t >= $nvertex);
# Match the edge connecting those sub-blossoms.
$mate[$endpoint[$p]] = $p ^ 1;
$mate[$endpoint[$p^1]] = $p;
DBG("PAIR ", $endpoint[$p], " ", $endpoint[$p^1], " k=", $p>>1) if ($DBG);
}
# Rotate the list of sub-blossoms to put the new base at the front.
my $n = scalar(@{$blossomchilds[$b]});
$blossomchilds[$b] = [ @{$blossomchilds[$b]}[$i .. ($n-1)],
@{$blossomchilds[$b]}[0 .. ($i-1)] ];
lib/Graph/Matching.pm view on Meta::CPAN
# swaps matched/unmatched edges over an alternating path between two
# single vertices; the augmenting path runs through edge $k, which
# connects a pair of S vertices.
local *augmentmatching = sub {
my ($k) = @_;
my $v = $endpoint[2*$k];
my $w = $endpoint[2*$k+1];
DBG("augmentmatching($k) v=$v w=$w") if ($DBG);
DBG("PAIR $v $w k=$k") if ($DBG);
foreach my $p (2*$k+1, 2*$k) {
my $s = $endpoint[$p^1];
# Match vertex s to remote endpoint p. Then trace back from s
# until we find a single vertex, swapping matched and unmatched
# edges as we go.
while (1) {
my $bs = $inblossom[$s];
assert($label[$bs] == 1 &&
lib/Graph/Matching.pm view on Meta::CPAN
augmentblossom($bs, $s) if ($bs >= $nvertex);
# Update $mate[$s]
$mate[$s] = $p;
# Trace one step back.
last if ($labelend[$bs] == -1); # stop at single vertex
my $t = $endpoint[$labelend[$bs]];
my $bt = $inblossom[$t];
assert($label[$bt] == 2);
# Trace one step back.
assert($labelend[$bt] >= 0);
$s = $endpoint[$labelend[$bt]];
my $j = $endpoint[$labelend[$bt] ^ 1];
# Augment through the T-blossom from j to base.
assert($blossombase[$bt] == $t);
augmentblossom($bt, $j) if ($bt >= $nvertex);
# Update $mate[$j]
$mate[$j] = $labelend[$bt];
# Keep the opposite endpoint;
# it will be assigned to $mate[$s] in the next step.
$p = $labelend[$bt] ^ 1;
DBG("PAIR $s $t k=", $p>>1) if ($DBG);
}
}
lib/Graph/Matching.pm view on Meta::CPAN
assert(!defined($_) || $_ >= 0);
}
# 0. all edges have non-negative slack and
# 1. all matched edges have zero slack;
foreach my $k (0 .. ($nedge-1)) {
my $v = $endpoint[2*$k];
my $w = $endpoint[2*$k+1];
my $weight = $graph->[$k]->[2];
my $s = $dualvar[$v] + $dualvar[$w] - 2 * $weight;
my @vblossoms = ( $v );
my @wblossoms = ( $w );
push @vblossoms, $blossomparent[$vblossoms[-1]]
lib/Graph/Matching.pm view on Meta::CPAN
foreach my $b ($nvertex .. (2*$nvertex-1)) {
if (defined($blossombase[$b]) && $dualvar[$b] > 0) {
assert((scalar(@{$blossomendps[$b]}) & 1) == 1);
for (my $j = 1; $j <= $#{$blossomendps[$b]}; $j += 2) {
my $p = $blossomendps[$b]->[$j];
assert($mate[$endpoint[$p]] == ($p^1));
assert($mate[$endpoint[$p^1]] == $p);
}
}
}
# Ok.
};
lib/Graph/Matching.pm view on Meta::CPAN
local *checkdelta2 = sub {
foreach my $v (0 .. ($nvertex-1)) {
if ($label[$inblossom[$v]] == 0) {
my $bd;
foreach my $p (@{$neighbend[$v]}) {
my $w = $endpoint[$p];
if ($label[$inblossom[$w]] == 1) {
my $d = slack($p >> 1);
$bd = $d if (!defined($bd) || $d < $bd);
}
}
lib/Graph/Matching.pm view on Meta::CPAN
foreach my $b (0 .. (2*$nvertex-1)) {
if (defined($blossomparent[$b]) && $blossomparent[$b] == -1 &&
$label[$b] == 1) {
foreach my $v (blossomleaves($b)) {
foreach my $p (@{$neighbend[$v]}) {
my $w = $endpoint[$p];
if ($inblossom[$w] != $b && $label[$inblossom[$w]] == 1) {
my $d = slack($p>>1);
$bd = $d if (!defined($bd) || $d < $bd);
}
}
}
if ($bestedge[$b] != -1) {
my $w = $endpoint[$bestedge[$b]];
my $v = $endpoint[$bestedge[$b]^1];
assert($inblossom[$v] == $b);
assert($inblossom[$w] != $b);
assert($label[$inblossom[$w]] == 1 && $label[$inblossom[$v]] == 1);
my $d = slack($bestedge[$b]>>1);
$tbd = $d if (!defined($tbd) || $d < $tbd);
lib/Graph/Matching.pm view on Meta::CPAN
assert($label[$inblossom[$v]] == 1);
# Scan its neighbours:
foreach my $p (@{$neighbend[$v]}) {
# w is a neighbour to v
my $w = $endpoint[$p];
# ignore blossom-internal edges
next if ($inblossom[$v] == $inblossom[$w]);
# check whether edge has zero slack
my $kslack;
if (!$allowedge[$p>>1]) {
lib/Graph/Matching.pm view on Meta::CPAN
# No further improvement possible; optimum reached.
last;
} elsif ($deltatype == 2) {
# Use the least-slack edge to continue the search.
$allowedge[$deltaedge>>1] = 1;
my $v = $endpoint[$deltaedge];
assert($label[$inblossom[$v]] == 1);
push @queue, $v;
} elsif ($deltatype == 3) {
# Use the least-slack edge to continue the search.
$allowedge[$deltaedge>>1] = 1;
my $v = $endpoint[$deltaedge];
assert($label[$inblossom[$v]] == 1);
DBG("PUSH $v") if ($DBG);
push @queue, $v;
} elsif ($deltatype == 4) {
# Expand the least-z blossom.
lib/Graph/Matching.pm view on Meta::CPAN
# Return %ret such that $ret[$v] is the vertex to which $v is paired.
my %ret;
for (my $v = 0; $v < $nvertex; $v++) {
if ($mate[$v] != -1) {
assert($endpoint[$mate[$endpoint[$mate[$v]]]] == $v);
$ret{$nodelist[$v]} = $nodelist[$endpoint[$mate[$v]]];
}
}
undef @nodelist;
undef %nodemap;
undef @endpoint;
undef @neighbend;
undef @mate;
undef @label;
undef @labelend;
undef @inblossom;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graph/Undirected/Hamiltonicity/Transforms.pm view on Meta::CPAN
return ( $required_graph, $g1 );
}
##########################################################################
# For each required walk, delete the edge connecting its endpoints,
# as such an edge would make the graph non-Hamiltonian, and therefore
# the edge can never be part of a Hamiltonian cycle.
sub delete_cycle_closing_edges {
output("Entering delete_cycle_closing_edges()<BR/>");
lib/Graph/Undirected/Hamiltonicity/Transforms.pm view on Meta::CPAN
$g1->delete_edge($vertex, $other_vertex);
$required_graph->delete_edge($vertex, $other_vertex);
$deleted_edges++;
output( "Deleted edge $vertex=$other_vertex"
. ", between endpoints of a required walk.<BR/>" );
}
if ( $deleted_edges ) {
my $s = $deleted_edges == 1 ? '' : 's';
output("Shrank the graph by removing $deleted_edges edge$s.<BR/>");
lib/Graph/Undirected/Hamiltonicity/Transforms.pm view on Meta::CPAN
my %vertices;
my @edges;
foreach my $chunk ( split( /\,/, $string ) ) {
if ( $chunk =~ /=/ ) {
my @endpoints = map {s/\b0+([1-9])/$1/gr}
split( /=/, $chunk );
next if $endpoints[0] == $endpoints[1];
push @edges, \@endpoints;
$vertices{ $endpoints[0] } = 1;
$vertices{ $endpoints[1] } = 1;
} else {
$vertices{$chunk} = 1;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/GraphQL/Client.pm view on Meta::CPAN
=head1 ATTRIBUTES
=head2 url
The URL of a GraphQL endpoint, e.g. C<"http://myapiserver/graphql">.
=head2 unpack
Whether or not to "unpack" the response, which enables a different style for error-handling.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/GraphQL/Plugin/Convert/OpenAPI.pm view on Meta::CPAN
return $obj if !$ref;
$ref =~ s{^#}{};
$schema->get($ref);
}
sub _kind2name2endpoint {
my ($paths, $schema, $name2type, $type2info) = @_;
my %kind2name2endpoint;
for my $path (keys %$paths) {
for my $method (grep $paths->{$path}{$_}, @METHODS) {
my $info = $paths->{$path}{$method};
my $op_id = $info->{operationId} || $method.'_'._trim_name($path);
my $fieldname = _trim_name($op_id);
my $kind = $METHOD2MUTATION{$method} ? 'mutation' : 'query';
$type2info->{ucfirst $kind}{field2operationId}{$fieldname} = $op_id;
my @successresponses = map _resolve_schema_ref($_, $schema),
map $info->{responses}{$_},
grep /^2/, keys %{$info->{responses}};
DEBUG and _debug("_kind2name2endpoint($path)($method)($fieldname)($op_id)", $info->{responses}, \@successresponses);
my @responsetypes = map _get_type(
$_->{schema}, $fieldname.'Return',
$name2type,
$type2info,
), @successresponses;
lib/GraphQL/Plugin/Convert/OpenAPI.pm view on Meta::CPAN
($argfield => {
type => _apply_modifier($_->{required} && 'non_null', $type),
$_->{description} ? (description => $_->{description}) : (),
})
} @parameters;
DEBUG and _debug("_kind2name2endpoint($fieldname) params", \%args);
my $description = $info->{summary} || $info->{description};
$kind2name2endpoint{$kind}->{$fieldname} = +{
type => $union,
$description ? (description => $description) : (),
%args ? (args => \%args) : (),
};
}
}
(\%kind2name2endpoint);
}
# possible "kind"s: scalar enum type input union interface
# mutates %$name2typeused - is boolean
sub _walk_type {
lib/GraphQL/Plugin/Convert/OpenAPI.pm view on Meta::CPAN
_trim_name($name), $defs->{$name},
\%name2type,
\%type2info,
);
}
my ($kind2name2endpoint) = _kind2name2endpoint(
$openapi_schema->get("/paths"), $openapi_schema,
\%name2type,
\%type2info,
);
for my $kind (keys %$kind2name2endpoint) {
$name2type{ucfirst $kind} = +{
kind => 'type',
name => ucfirst $kind,
fields => { %{ $kind2name2endpoint->{$kind} } },
};
}
my %name2typeused;
_walk_type(ucfirst $_, \%name2typeused, \%name2type)
for keys %$kind2name2endpoint;
push @ast, map $name2type{$_}, keys %name2typeused;
+{
schema => GraphQL::Schema->from_ast(\@ast),
root_value => OpenAPI::Client->new($openapi_schema->data, %appargs),
resolver => make_field_resolver(\%type2info),
view all matches for this distribution
view release on metacpan or search on metacpan
lib/GraphQL.pm view on Meta::CPAN
See L<GraphQL::Type> for description of how to create GraphQL types.
=head2 Introduction to GraphQL
GraphQL is a technology that lets clients talk to APIs via a single
endpoint, which acts as a single "source of the truth". This means clients
do not need to seek the whole picture from several APIs. Additionally,
it makes this efficient in network traffic, time, and programming effort:
=over
view all matches for this distribution
view release on metacpan or search on metacpan
lib/GraphViz.pm view on Meta::CPAN
sets the arrow direction. Can be one of: 'forward', 'back', 'both', 'none'
=item tailclip, headclip
when set to false disables endpoint shape clipping
=item arrowhead, arrowtail
sets the type for the arrow head or tail. Can be one of: 'none',
'normal', 'inv', 'dot', 'odot', 'invdot', 'invodot.'
view all matches for this distribution
view release on metacpan or search on metacpan
script/dtd4 view on Meta::CPAN
if ($nm eq 'node_id' && $t eq 'node_id') {
my $node_name = $n->{attributes}{name};
# If this node_id is part of an edge (immediately before/after edge_id),
# we still want its attributes, but we don't treat it as a standalone node block.
my $is_edge_endpoint = 0;
if ($i + 1 < @body && ($body[$i + 1]{name} // '') eq 'edge_id') {
$is_edge_endpoint = 1;
}
if ($i > 0 && ($body[$i - 1]{name} // '') eq 'edge_id') {
$is_edge_endpoint = 1;
}
my %node_attr;
if ($n->{daughters} && @{ $n->{daughters} }) {
for my $c (@{ $n->{daughters} }) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graphics/Fig/Arc.pm view on Meta::CPAN
my $dx = $x1 - $xc;
my $dy = $y1 - $yc;
my $r = sqrt($dx * $dx + $dy * $dy);
#
# First, find the bounding box of the endpoints. Then for each
# axis the arc crosses, expand the box as needed.
#
my $bbox = Graphics::Fig::Parameters::getbboxFromPoints($point1, $point3);
if (&crosses_axis($point1, $point3, [ $xc - $r, $yc ]) * $angle > 0) {
if ($xc - $r < ${$bbox}[0][0]) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graphics/Framebuffer.pm view on Meta::CPAN
double dx = x1d - x0;
double dy = y1d - y0;
double gradient = (dx == 0.0) ? 1.0 : dy / dx;
/* handle first endpoint */
double xend = roundd(x0);
double yend = y0 + gradient * (xend - x0);
double xgap = rfpart(x0 + 0.5);
long xpxl1 = (long)xend;
long ypxl1 = (long)floor(yend);
/* plot first endpoint */
double intery = yend + gradient; /* first y-intersection for the main loop */
/* First endpoint pixels */
plot_aa_pixel(framebuffer,
color,
bcolor,
alpha,
bytes_per_pixel,
lib/Graphics/Framebuffer.pm view on Meta::CPAN
steep,
xpxl1,
ypxl1 + 1,
fpart(yend) * xgap);
/* handle second endpoint */
xend = roundd(x1d);
yend = y1d + gradient * (xend - x1d);
xgap = fpart(x1d + 0.5);
long xpxl2 = (long)xend;
long ypxl2 = (long)floor(yend);
lib/Graphics/Framebuffer.pm view on Meta::CPAN
my $gradient = $dy / $dx;
my @xends;
my $intery;
# handle the endpoints
foreach my $xy ([$x0, $y0], [$x1, $y1]) {
my ($x, $y) = @{$xy};
my $xend = int($x + 0.5); # POSIX::lround($x);
my $yend = $y + $gradient * ($xend - $x);
my $xgap = _rfpart($x + 0.5);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graphics/Penplotter/GcodeXY.pm view on Meta::CPAN
# We need DEVICE coordinates here for obvious reasons
#
sub _warn ($self, $x, $y) {
my ( $x0clip, $y0clip, $x1clip, $y1clip, $info );
if ( !$self->{warn} ) { return 0 }
# we check only the endpoint for now.
# just assume the line started at (0.1, 0.1)
if ( ( $x < 0 ) || ( $y < 0 ) ) {
print STDOUT "Out of bound: ($x,$y)" . $EOL;
return 0;
}
lib/Graphics/Penplotter/GcodeXY.pm view on Meta::CPAN
Replace the current segment path with its anamorphic distortion for a
cylindrical mirror of radius C<$R> centred at C<($cx, $cy)>, then flush the
path via C<stroke>.
The intended image is whatever is already in the segment path when this method
is called. The bounding box of the existing drawable segment endpoints is
used as the image extent. Each endpoint is independently projected onto the
paper via the cylindrical mirror model; segments whose endpoints cannot be
projected are dropped, and path continuity is maintained automatically.
The C<$cx>, C<$cy>, C<$R>, and observer parameters must be expressed in the
same coordinate space as the segment path (device coordinates as used
internally by GcodeXY). For typical plots with no active transform this is
view all matches for this distribution
view release on metacpan or search on metacpan
unsigned int i;
int tag;
potrace_dpoint_t *c = NULL;
HV *segment = NULL;
HV *first_segment = NULL;
SV *last_endpoint = NULL;
hv_store(retval, "area", 4, newSViv(node->area), FALSE);
hv_store(retval, "sign", 4, newSVpvn((node->sign == '-' ? "-" : "+"), 1), FALSE);
hv_store(retval, "curve", 5, newRV_noinc((SV *)curve), FALSE);
segment = newHV();
if (first_segment == NULL)
first_segment = segment;
if (last_endpoint) {
hv_store(segment, "begin", 5, last_endpoint, FALSE);
last_endpoint = NULL;
}
hv_store(segment, "end", 3, _make_point(c+2), FALSE);
last_endpoint = _make_point(c+2); /* "begin" of the next segment */
if (tag == POTRACE_CORNER) {
hv_store(segment, "type", 4, newSVpvn("corner", 6), FALSE);
hv_store(segment, "corner", 6, _make_point(c+1), FALSE);
}
hv_store(segment, "p1", 2, _make_point(c), FALSE);
hv_store(segment, "p2", 2, _make_point(c+1), FALSE);
}
av_push(curve, newRV_noinc((SV *)segment));
}
if (last_endpoint)
hv_store(first_segment, "begin", 5, last_endpoint, FALSE);
return newRV_noinc((SV *)retval);
}
SV *_make_listpath(potrace_path_t *plist) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/GrowthForecast/Aggregator/Callback.pm view on Meta::CPAN
sub run {
my $self = shift;
my %args = @_;
my $service = $args{service} // die "Missing mandatory parameter: service";
my $endpoint = $args{endpoint} // die "Missing mandatory parameter: endpoint";
my $ua = $args{ua} // die "Missing mandatory parameter: ua";
$endpoint =~ s!/$!!;
my $url = "$endpoint/$service/$self->{section}/$self->{name}";
my ($number) = $self->code->();
my $req = POST $url, [
number => $number,
description => encode_utf8($self->description),
lib/GrowthForecast/Aggregator/Callback.pm view on Meta::CPAN
Service name.
This module send request to "/api/$service/$section/$name"
=item endpoint
Endpoint URL, contains '/api'.
E.g. http://example.com/api/
view all matches for this distribution
view release on metacpan or search on metacpan
public/js/site.js view on Meta::CPAN
setTimeout(function(){ preview_complex_graph($('#complex-form')) },10);
});
var service_tree;
$.ajax({
url: $('#service_tree').data('endpoint'),
cache: false,
async: false,
dataType: 'json'
}).done(function(data){ service_tree = data })
.fail(function(){
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Grpc/Client/AbstractCall.pm view on Meta::CPAN
sub getMetadata {
my $self = shift;
return $self->{_metadata};
}
## @return string The URI of the endpoint.
sub getPeer {
my $self = shift;
return $self->{_call}->getPeer();
}
view all matches for this distribution
view release on metacpan or search on metacpan
share/public/guaclite.js view on Meta::CPAN
/**
* Add the specified line to the current path.
*
* @param {Guacamole.Layer} layer The layer to draw upon.
* @param {Number} x The X coordinate of the endpoint of the line to draw.
* @param {Number} y The Y coordinate of the endpoint of the line to draw.
*/
this.lineTo = function(layer, x, y) {
scheduleTask(function __display_lineTo() {
layer.lineTo(x, y);
});
share/public/guaclite.js view on Meta::CPAN
* @param {Guacamole.Layer} layer The layer to draw upon.
* @param {Number} cp1x The X coordinate of the first control point.
* @param {Number} cp1y The Y coordinate of the first control point.
* @param {Number} cp2x The X coordinate of the second control point.
* @param {Number} cp2y The Y coordinate of the second control point.
* @param {Number} x The X coordinate of the endpoint of the curve.
* @param {Number} y The Y coordinate of the endpoint of the curve.
*/
this.curveTo = function(layer, cp1x, cp1y, cp2x, cp2y, x, y) {
scheduleTask(function __display_curveTo() {
layer.curveTo(cp1x, cp1y, cp2x, cp2y, x, y);
});
share/public/guaclite.js view on Meta::CPAN
};
/**
* Add the specified line to the current path.
*
* @param {Number} x The X coordinate of the endpoint of the line to draw.
* @param {Number} y The Y coordinate of the endpoint of the line to draw.
*/
this.lineTo = function(x, y) {
// Start a new path if current path is closed
if (pathClosed) {
share/public/guaclite.js view on Meta::CPAN
*
* @param {Number} cp1x The X coordinate of the first control point.
* @param {Number} cp1y The Y coordinate of the first control point.
* @param {Number} cp2x The X coordinate of the second control point.
* @param {Number} cp2y The Y coordinate of the second control point.
* @param {Number} x The X coordinate of the endpoint of the curve.
* @param {Number} y The Y coordinate of the endpoint of the curve.
*/
this.curveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {
// Start a new path if current path is closed
if (pathClosed) {
share/public/guaclite.js view on Meta::CPAN
tunnel.setUUID(connect_xmlhttprequest.responseText);
// Mark as open
tunnel.setState(Guacamole.Tunnel.State.OPEN);
// Ping tunnel endpoint regularly to test connection stability
pingInterval = setInterval(function sendPing() {
tunnel.sendMessage("nop");
}, PING_FREQUENCY);
// Start reading data
share/public/guaclite.js view on Meta::CPAN
socket = new WebSocket(tunnelURL + "?" + data, "guacamole");
socket.onopen = function(event) {
reset_timeout();
// Ping tunnel endpoint regularly to test connection stability
pingInterval = setInterval(function sendPing() {
tunnel.sendMessage(Guacamole.Tunnel.INTERNAL_DATA_OPCODE,
"ping", new Date().getTime());
}, PING_FREQUENCY);
view all matches for this distribution
view release on metacpan or search on metacpan
- Downgraded to use Moo.
- Added standard load test script (t/00-load.t).
- Removed '+x' attributes from some of the test scripts.
0.06 2016-04-12 MANWAR
* Updated endpoint for API.
* Updated param name for api key i.e. 'api-key'.
* Tidied up pod document.
* Updated github repository details.
* Removed '+x' attrbutes from Build.PL, MANIFEST and README.
* Tidied up Changes file.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTML/Dojo/editions.pm view on Meta::CPAN
dojo.debug("your JSON wasn't comment filtered!");
return "";
}
return _143.substring(_144+2,_145);
}
dojo.debug("please consider using a mimetype of text/json-comment-filtered to avoid potential security issues with JSON endpoints");
return _143;
},load:function(type,data,_148,_149){
},error:function(type,_14b,_14c,_14d){
},timeout:function(type,_14f,_150,_151){
},handle:function(type,data,_154,_155){
lib/HTML/Dojo/editions.pm view on Meta::CPAN
dojo.debug("your JSON wasn't comment filtered!");
return "";
}
return _735.substring(_736+2,_737);
}
dojo.debug("please consider using a mimetype of text/json-comment-filtered to avoid potential security issues with JSON endpoints");
return _735;
},load:function(type,data,_73a,_73b){
},error:function(type,_73d,_73e,_73f){
},timeout:function(type,_741,_742,_743){
},handle:function(type,data,_746,_747){
lib/HTML/Dojo/editions.pm view on Meta::CPAN
dojo.debug("your JSON wasn't comment filtered!");
return "";
}
return _143.substring(_144+2,_145);
}
dojo.debug("please consider using a mimetype of text/json-comment-filtered to avoid potential security issues with JSON endpoints");
return _143;
},load:function(type,data,_148,_149){
},error:function(type,_14b,_14c,_14d){
},timeout:function(type,_14f,_150,_151){
},handle:function(type,data,_154,_155){
lib/HTML/Dojo/editions.pm view on Meta::CPAN
dojo.debug("your JSON wasn't comment filtered!");
return "";
}
return _5a2.substring(_5a3+2,_5a4);
}
dojo.debug("please consider using a mimetype of text/json-comment-filtered to avoid potential security issues with JSON endpoints");
return _5a2;
},load:function(type,data,_5a7,_5a8){
},error:function(type,_5aa,_5ab,_5ac){
},timeout:function(type,_5ae,_5af,_5b0){
},handle:function(type,data,_5b3,_5b4){
lib/HTML/Dojo/editions.pm view on Meta::CPAN
dojo.debug("your JSON wasn't comment filtered!");
return "";
}
return _735.substring(_736+2,_737);
}
dojo.debug("please consider using a mimetype of text/json-comment-filtered to avoid potential security issues with JSON endpoints");
return _735;
},load:function(type,data,_73a,_73b){
},error:function(type,_73d,_73e,_73f){
},timeout:function(type,_741,_742,_743){
},handle:function(type,data,_746,_747){
lib/HTML/Dojo/editions.pm view on Meta::CPAN
dojo.debug("your JSON wasn't comment filtered!");
return "";
}
return _19e.substring(_19f+2,_1a0);
}
dojo.debug("please consider using a mimetype of text/json-comment-filtered to avoid potential security issues with JSON endpoints");
return _19e;
},load:function(type,data,_1a3,_1a4){
},error:function(type,_1a6,_1a7,_1a8){
},timeout:function(type,_1aa,_1ab,_1ac){
},handle:function(type,data,_1af,_1b0){
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTML/FormHandlerX/JQueryRemoteValidator.pm view on Meta::CPAN
use JSON ();
has_field _validation_scripts => (type => 'JavaScript', set_js_code => '_js_code_for_validation_scripts');
has validation_endpoint => (is => 'rw', isa => 'Str', default => '/ajax/formvalidator');
has jquery_validator_link => (is => 'rw', isa => 'Str', default => 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js');
has skip_remote_validation_types => (is => 'rw', isa => 'ArrayRef', default => sub { [ qw(Submit Hidden noCAPTCHA Display JSON JavaScript) ] });
lib/HTML/FormHandlerX/JQueryRemoteValidator.pm view on Meta::CPAN
return $js_profile;
}
method _build_remote_rule ($field) {
my $remote_rule = {
url => sprintf("%s/%s/%s", $self->validation_endpoint, $self->name, $field->id),
type => 'POST',
data => $self->name . "_data_collector",
};
return $remote_rule;
lib/HTML/FormHandlerX/JQueryRemoteValidator.pm view on Meta::CPAN
=head1 CONFIGURATION AND SETUP
The purpose of this package is to build a set of JQuery scripts and inject them
into your forms. The scripts send user input to your server where you must
provide an endpoint that can validate the fields. Since you already have an
HTML::FormHandler form, you can use that.
The package uses the remote validation feature of the JQuery Validator
framework. This also takes care of updating your form to notify the user of
errors and successes while they fill in the form. You will most likely want
lib/HTML/FormHandlerX/JQueryRemoteValidator.pm view on Meta::CPAN
=item JQuery validator
See the C<jquery_validator_link> attribute.
=item Server-side validation endpoint
See the C<validation_endpoint> attribute.
=item Some JS fragments to update the form
=item CSS to prettify it all
lib/HTML/FormHandlerX/JQueryRemoteValidator.pm view on Meta::CPAN
has '+jqr_validate_options' => (default => sub {$jqr_validate_options});
=head2 Class (form) attributes
=head3 C<validation_endpoint>
Default: /ajax/formvalidator
The form data will be POSTed to C<[validation_endpoint]/[form_name]/[field_name]>.
Note that *all* fields are submitted, not just the field being validated.
You must write the code to handle this submission. The response should be a JSON
string, either C<true> if the field passed its tests, or a message describing
view all matches for this distribution
view release on metacpan or search on metacpan
azure-pipelines.yml view on Meta::CPAN
resources:
repositories:
- repository: ci-perl-helpers
type: github
name: houseabsolute/ci-perl-helpers
endpoint: houseabsolute
stages:
- template: templates/helpers/build.yml@ci-perl-helpers
parameters:
debug: true
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTML/OSM.pm view on Meta::CPAN
An object to use for HTTP requests.
If not provided, a default user agent is created.
=item * C<host>
The API host endpoint.
Defaults to L<https://nominatim.openstreetmap.org/search>.
=item * C<width>
Width (in pixels or using your own unit), the default is 600px.
view all matches for this distribution
view release on metacpan or search on metacpan
"Gisle Aas <gisle@aas.no>",
"Graham Knop <haarg@haarg.org>",
"Jacques Germishuys <jacquesg@striata.com>",
"James Raspass <jraspass@gmail.com>",
"Jess Robinson <castaway@desert-island.me.uk>",
"Jon Jensen <jon@endpoint.com>",
"Lukas Mai <lukasmai.403@gmail.com>",
"Michal Josef \u0160pa\u010dek <mspacek@redhat.com>",
"Mike South <msouth@gmail.com>",
"Nicholas Clark <nick@ccl4.org>",
"Nicolas R <nicolas@atoomic.org>",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTML/TableContent/Template/Base.pm view on Meta::CPAN
cell all => ( alternate_classes => qw['one', 'two'] );
sub _render_header {
my ($self, $header) = @_;
return ['<a href="some/endpoint?sort=%s">%s</a>', 'template_attr', 'text'];
}
sub _even_rows {
return ['<div>%s</div>', '_render_element'];
}
view all matches for this distribution
view release on metacpan or search on metacpan
"Hao Wu <hwu@intellisurvey.com>",
"Ilya Rassadin <elcamlost@gmail.com>",
"James Raspass <jraspass@gmail.com>",
"James Waters <james@jcwaters.co.uk>",
"joatis <joatis3@gmail.com>",
"Jon Jensen <jon@endpoint.com>",
"Konstantin A. Pustovalov <konstantin.pustovalov@quantumsoft.ru>",
"ktat <ktat.is@gmail.com>",
"lsaunders <lsaunders@dev05.backbone.i5invest.com>",
"Mahdi Zarei <ymgsmz@gmail.com>",
"Marco Fontani <MFONTANI@cpan.org>",
view all matches for this distribution
view release on metacpan or search on metacpan
lib/HTTP/Request.pm view on Meta::CPAN
are a few examples.
=head2 Simple POST
Here, we'll create a simple POST request that could be used to send JSON data
to an endpoint.
#!/usr/bin/env perl
use strict;
use warnings;
view all matches for this distribution