Commit Graph

41 Commits

Author SHA1 Message Date
Dan Kortschak
5b0db962f3 graph/path: make AllShortest safe for length zero 2018-11-21 07:57:39 +10:30
Dan Kortschak
969ecdd209 graph: remove Has method from Graph and Multigraph 2018-10-12 17:57:01 +10:30
Dan Kortschak
46d85b5bdf graph: avoid issues around graph node retrieval subtleties
With the approach to graph node mutation on edge setting the previously
existed there was an issue that the edge last used connect a pair of
nodes could result in a difference in the nodes being returned by a node
query compared to the same node associated with edges returned from an
edge query.

This change avoids dealing with that by making it implementation
dependent and stating this, and by making all the node-storing graphs
we provide mutate the nodes when edges are set.
2018-09-29 19:26:44 +09:30
Dan Kortschak
b73a2c92ff graph: add node, edge and line iterators 2018-09-23 09:25:56 +09:30
Dan Kortschak
0d92706921 graph/path: add Yen k-shortest paths implementation
Also add Rishi Desai, primary-author of the commit.
2018-08-22 07:50:28 +09:30
Dan Kortschak
a63e6adee3 graph/path/internal: move grid graphs into testgraphs 2018-06-07 19:37:48 +09:30
Dan Kortschak
9b6dcf36f0 all: fix up missing or malformatted package doc comments 2018-06-07 19:37:48 +09:30
Dan Kortschak
f5d91d72f8 graph/path: allow incremental path building for Dijkstra 2018-05-24 07:13:55 +09:30
Dan Kortschak
fa6741ae52 graph/path: tighten use of johnsonWeightAdjuster
The only call to Has for johnsonWeightAdjuster is in the preamble to
BellmanFordFor, which is always passed the known query node. If Has is
called when the graph is not in the Bellman-Ford mode or the Has query
is not the query node, the call was invalid and we should panic.
2018-05-09 22:09:45 +09:30
Dan Kortschak
32a6369498 graph: use int64 for edge and line removal 2018-05-07 19:11:10 +09:30
Dan Kortschak
6b03bc22e1 graph: use int64 for node retrieval 2018-03-24 09:21:44 +10:30
kortschak
299547a6f4 Revert "graph: change Edge interface to include ID method"
This reverts commit 1a83fdba7a.

Further design discussion leads to a better approach with an additional
edge-type interface.
2017-12-14 08:24:55 +10:30
kortschak
1a83fdba7a graph: change Edge interface to include ID method
This is to allow future handling of multigraphs.
2017-12-11 08:06:56 +10:30
kortschak
fa0c5aa7bc all: use golang.org/x/exp/rand instead of math/rand 2017-11-17 11:52:34 +10:30
kortschak
805531d142 all: change capitalization of gonum in license header 2017-11-02 06:54:08 +10:30
kortschak
21d5891471 all: remove go1.7 build constraints 2017-10-27 13:48:47 +10:30
kortschak
f818f8f7a9 graph/path: allow Shortest to traverse negative cycles
Also add checks for cases where negative cycles exist but are not marked
to protect against future shortest path function additions.
2017-09-15 08:17:25 +09:30
kortschak
a18d79f600 graph/{internal,path,topo}: factor reverse function out into internal 2017-09-15 07:05:29 +09:30
kortschak
1b3b29f16b graph/path: implement sophisticated algorithm
Both algorithms are included since the LTA appears to beat the SLTA for
all normal uses, but the SLTA beats the LTA for very large dense graphs.

Leave tools in the benchmark code to allow users to determine which one
they want to use for their data.
2017-09-12 09:50:52 +09:30
kortschak
9baf9959f7 graph/path: add benchmarks for Dominators
The initial test cases are from Robin Eklind's decomp project, the DOT
files were generated using his instructions:

    git clone https://github.com/decomp/testdata
    go get github.com/decomp/decomp/cmd/ll2dot
    cd testdata/pathological/testdata
    ll2dot *.ll
2017-09-12 09:50:52 +09:30
kortschak
c2e0c99d23 graph/path: replace map and slice index chasing with pointer chasing 2017-09-12 09:50:52 +09:30
kortschak
fbd569ccc4 Revert "graph/path: replace recursive dfs with iterative implementation"
This reverts commit 4c195282fab50c627add36d97e58caded3e85742.

The iterative dfs looks like it will be more convoluted when the arrays
are removed into a Lengauer & Tarjan node holding each graph.Node's
details.

Leaving the change in the tree to help figure out an iterative
implementation later if needed.
2017-09-12 09:50:52 +09:30
kortschak
bff6fc28f1 graph/path: add dominator tree API 2017-09-12 09:50:52 +09:30
kortschak
4cdef9a92e graph/path: replace recursive dfs with iterative implementation 2017-09-12 09:50:52 +09:30
kortschak
5817a3ce4a graph/path: replace Dominators with naive Lengauer and Tarjan
Much of the sparse ID mapping can be condensed into slice storage, but
this provides a sane starting point.
2017-09-12 09:50:52 +09:30
kortschak
acd06c4949 graph/path: revise spanning tree signatures and behaviours 2017-08-24 10:21:20 +09:30
kortschak
f739fbf133 graph/simple: separate weighted and unweighted edge implementations 2017-08-24 10:21:20 +09:30
kortschak
7ba61f0ead graph/...: remove Weight method from Edge 2017-08-24 10:21:15 +09:30
kortschak
ffa13e8edb graph,graph/{community,network,path}: rename WeightedGraph => Weighted 2017-08-24 10:21:15 +09:30
kortschak
715b695621 graph,graph/{network,path}: remove Weighter interface 2017-08-24 10:21:15 +09:30
kortschak
8508095a22 graph,graph/{community,path}: use weighted graph types 2017-08-24 10:21:15 +09:30
mewmew
0ebdd59ba5 graph: move NewEdge method from encoding.Builder to graph.EdgeAdder
Also rename graph.EdgeSetter to graph.EdgeAdder.

Fixes #56.
2017-08-18 03:51:30 +02:00
kortschak
15ecc07d40 graph/path/...: update for int64 IDs 2017-07-02 08:38:42 +09:30
kortschak
7af70dd796 all: fix many go vet errors 2017-06-20 16:29:35 +09:30
kortschak
a1347c0243 all: fix spelling errors 2017-06-20 16:29:35 +09:30
kortschak
6557c5dc64 all: simplify code identified by gosimple 2017-06-20 15:04:11 +09:30
Brendan Tracey
0d639745f1 all: update packages from mat64 to mat.
This mostly changes package name and code, but also fixes a couple of name clashes with the new package names
2017-06-13 10:28:21 -06:00
kortschak
6d2a59dbb7 all: run gofmt -s 2017-05-31 16:43:23 +09:30
kortschak
37850ca814 all: add canonical imports 2017-05-25 16:07:18 +09:30
Brendan Tracey
d33397aa65 all: change import paths 2017-05-23 00:03:03 -06:00
Brendan Tracey
059a6c43f9 graph: imported graph as a subtree 2017-05-23 00:02:59 -06:00