graph/{simple,multi}: clean up implementation organisation and do more rigorous testing
Created by: kortschak
The implementations provided in simple and multi have a lot of code duplication, but it has grown rather organically and without consistency between the implementations. This has resulted in a number of occasions where methods that should have been added to all implementations have been missed on some. This has been compounded by the sparsity of testing on those types.
So the files should be harmonised to enable ready comparison between the types and there should be a common test suite that exercises the behaviour we claim, similar to the approach in testblas and testlapack.
Code structure
-
Harmonise the code arrangement; using the godoc order seems the most sensible.
Testing general graphs
-
Return all nodes -
Return correct presence status of non/existing nodes -
Return all edges/lines -
Return correct presence status of non/existing edges/lines -
Return all adjacent nodes relevant to type ( From
,To
) -
Compare graph weight method with corresponding edge/line weight In addition, there are some type-specific tests -
Test matrix input/output from dense graphs
Testing mutable graphs
-
Test node addition -
Test node creation behaviour -
Test node deletion -
Test node deletion causes attached edges to be deleted -
Test edge/line setting -
Confirm simple graphs panic on self-edge setting -
Confirm multi graphs accept self-line setting -
Test edge/line creation behaviour -
Test edge/line deletion -
Test edge/line deletion does not cause edge/line endpoints to be deleted -
Test nodes corresponding to set edges/lines are updated in set edge operation