module Geometry.Trajectory.ReassembleLines (reassembleLines) where
import Data.Foldable
import Data.Map (Map)
import qualified Data.Map as M
import Data.Ord
import Data.Sequence (Seq, (|>))
import qualified Data.Sequence as Seq
import Prelude hiding (lines)
newtype UndirectedNeighbourMap a = UndirectedNeighbourMap (Map a (OneTwo a))
deriving (UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
(UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool)
-> (UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool)
-> Eq (UndirectedNeighbourMap a)
forall a.
Eq a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a.
Eq a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
== :: UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
$c/= :: forall a.
Eq a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
/= :: UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
Eq, Eq (UndirectedNeighbourMap a)
Eq (UndirectedNeighbourMap a)
-> (UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> Ordering)
-> (UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool)
-> (UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool)
-> (UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool)
-> (UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool)
-> (UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a)
-> (UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a)
-> Ord (UndirectedNeighbourMap a)
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Ordering
UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (UndirectedNeighbourMap a)
forall a.
Ord a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
forall a.
Ord a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Ordering
forall a.
Ord a =>
UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a
$ccompare :: forall a.
Ord a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Ordering
compare :: UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Ordering
$c< :: forall a.
Ord a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
< :: UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
$c<= :: forall a.
Ord a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
<= :: UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
$c> :: forall a.
Ord a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
> :: UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
$c>= :: forall a.
Ord a =>
UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
>= :: UndirectedNeighbourMap a -> UndirectedNeighbourMap a -> Bool
$cmax :: forall a.
Ord a =>
UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a
max :: UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a
$cmin :: forall a.
Ord a =>
UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a
min :: UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a
Ord, Int -> UndirectedNeighbourMap a -> ShowS
[UndirectedNeighbourMap a] -> ShowS
UndirectedNeighbourMap a -> String
(Int -> UndirectedNeighbourMap a -> ShowS)
-> (UndirectedNeighbourMap a -> String)
-> ([UndirectedNeighbourMap a] -> ShowS)
-> Show (UndirectedNeighbourMap a)
forall a. Show a => Int -> UndirectedNeighbourMap a -> ShowS
forall a. Show a => [UndirectedNeighbourMap a] -> ShowS
forall a. Show a => UndirectedNeighbourMap a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> UndirectedNeighbourMap a -> ShowS
showsPrec :: Int -> UndirectedNeighbourMap a -> ShowS
$cshow :: forall a. Show a => UndirectedNeighbourMap a -> String
show :: UndirectedNeighbourMap a -> String
$cshowList :: forall a. Show a => [UndirectedNeighbourMap a] -> ShowS
showList :: [UndirectedNeighbourMap a] -> ShowS
Show)
data OneTwo a = One !a | Two !a !a
deriving (OneTwo a -> OneTwo a -> Bool
(OneTwo a -> OneTwo a -> Bool)
-> (OneTwo a -> OneTwo a -> Bool) -> Eq (OneTwo a)
forall a. Eq a => OneTwo a -> OneTwo a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => OneTwo a -> OneTwo a -> Bool
== :: OneTwo a -> OneTwo a -> Bool
$c/= :: forall a. Eq a => OneTwo a -> OneTwo a -> Bool
/= :: OneTwo a -> OneTwo a -> Bool
Eq, Eq (OneTwo a)
Eq (OneTwo a)
-> (OneTwo a -> OneTwo a -> Ordering)
-> (OneTwo a -> OneTwo a -> Bool)
-> (OneTwo a -> OneTwo a -> Bool)
-> (OneTwo a -> OneTwo a -> Bool)
-> (OneTwo a -> OneTwo a -> Bool)
-> (OneTwo a -> OneTwo a -> OneTwo a)
-> (OneTwo a -> OneTwo a -> OneTwo a)
-> Ord (OneTwo a)
OneTwo a -> OneTwo a -> Bool
OneTwo a -> OneTwo a -> Ordering
OneTwo a -> OneTwo a -> OneTwo a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (OneTwo a)
forall a. Ord a => OneTwo a -> OneTwo a -> Bool
forall a. Ord a => OneTwo a -> OneTwo a -> Ordering
forall a. Ord a => OneTwo a -> OneTwo a -> OneTwo a
$ccompare :: forall a. Ord a => OneTwo a -> OneTwo a -> Ordering
compare :: OneTwo a -> OneTwo a -> Ordering
$c< :: forall a. Ord a => OneTwo a -> OneTwo a -> Bool
< :: OneTwo a -> OneTwo a -> Bool
$c<= :: forall a. Ord a => OneTwo a -> OneTwo a -> Bool
<= :: OneTwo a -> OneTwo a -> Bool
$c> :: forall a. Ord a => OneTwo a -> OneTwo a -> Bool
> :: OneTwo a -> OneTwo a -> Bool
$c>= :: forall a. Ord a => OneTwo a -> OneTwo a -> Bool
>= :: OneTwo a -> OneTwo a -> Bool
$cmax :: forall a. Ord a => OneTwo a -> OneTwo a -> OneTwo a
max :: OneTwo a -> OneTwo a -> OneTwo a
$cmin :: forall a. Ord a => OneTwo a -> OneTwo a -> OneTwo a
min :: OneTwo a -> OneTwo a -> OneTwo a
Ord, Int -> OneTwo a -> ShowS
[OneTwo a] -> ShowS
OneTwo a -> String
(Int -> OneTwo a -> ShowS)
-> (OneTwo a -> String) -> ([OneTwo a] -> ShowS) -> Show (OneTwo a)
forall a. Show a => Int -> OneTwo a -> ShowS
forall a. Show a => [OneTwo a] -> ShowS
forall a. Show a => OneTwo a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> OneTwo a -> ShowS
showsPrec :: Int -> OneTwo a -> ShowS
$cshow :: forall a. Show a => OneTwo a -> String
show :: OneTwo a -> String
$cshowList :: forall a. Show a => [OneTwo a] -> ShowS
showList :: [OneTwo a] -> ShowS
Show)
instance Ord a => Semigroup (UndirectedNeighbourMap a) where
UndirectedNeighbourMap Map a (OneTwo a)
x <> :: UndirectedNeighbourMap a
-> UndirectedNeighbourMap a -> UndirectedNeighbourMap a
<> UndirectedNeighbourMap Map a (OneTwo a)
y = Map a (OneTwo a) -> UndirectedNeighbourMap a
forall a. Map a (OneTwo a) -> UndirectedNeighbourMap a
UndirectedNeighbourMap (Map a (OneTwo a) -> UndirectedNeighbourMap a)
-> Map a (OneTwo a) -> UndirectedNeighbourMap a
forall a b. (a -> b) -> a -> b
$
(OneTwo a -> OneTwo a -> OneTwo a)
-> Map a (OneTwo a) -> Map a (OneTwo a) -> Map a (OneTwo a)
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
M.unionWith
(\OneTwo a
a OneTwo a
b -> case (OneTwo a
a,OneTwo a
b) of
(One a
a', One a
b') -> a -> a -> OneTwo a
forall a. a -> a -> OneTwo a
Two a
a' a
b'
(OneTwo a, OneTwo a)
_otherwise -> String -> OneTwo a
forall a. HasCallStack => String -> a
error (String -> OneTwo a)
-> ([String] -> String) -> [String] -> OneTwo a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [String] -> String
unwords ([String] -> OneTwo a) -> [String] -> OneTwo a
forall a b. (a -> b) -> a -> b
$
[ String
"Insertion of more than two neighbours in a UndirectedNeighbourMap."
, String
"Are you sure all your points have at most two neighbours?" ]
)
Map a (OneTwo a)
x
Map a (OneTwo a)
y
instance Ord a => Monoid (UndirectedNeighbourMap a) where
mempty :: UndirectedNeighbourMap a
mempty = Map a (OneTwo a) -> UndirectedNeighbourMap a
forall a. Map a (OneTwo a) -> UndirectedNeighbourMap a
UndirectedNeighbourMap Map a (OneTwo a)
forall a. Monoid a => a
mempty
lnmLookupDeleteForward :: Ord a => a -> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDeleteForward :: forall a.
Ord a =>
a
-> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDeleteForward a
x (UndirectedNeighbourMap Map a (OneTwo a)
m) = case a -> Map a (OneTwo a) -> Maybe (OneTwo a)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup a
x Map a (OneTwo a)
m of
Maybe (OneTwo a)
Nothing -> Maybe (a, UndirectedNeighbourMap a)
forall a. Maybe a
Nothing
Just (One a
a) -> (a, UndirectedNeighbourMap a)
-> Maybe (a, UndirectedNeighbourMap a)
forall a. a -> Maybe a
Just (a
a, Map a (OneTwo a) -> UndirectedNeighbourMap a
forall a. Map a (OneTwo a) -> UndirectedNeighbourMap a
UndirectedNeighbourMap (a -> Map a (OneTwo a) -> Map a (OneTwo a)
forall k a. Ord k => k -> Map k a -> Map k a
M.delete a
x Map a (OneTwo a)
m))
Just (Two a
a a
b) -> (a, UndirectedNeighbourMap a)
-> Maybe (a, UndirectedNeighbourMap a)
forall a. a -> Maybe a
Just (a
a, Map a (OneTwo a) -> UndirectedNeighbourMap a
forall a. Map a (OneTwo a) -> UndirectedNeighbourMap a
UndirectedNeighbourMap (a -> OneTwo a -> Map a (OneTwo a) -> Map a (OneTwo a)
forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert a
x (a -> OneTwo a
forall a. a -> OneTwo a
One a
b) Map a (OneTwo a)
m))
lnmLookupDeleteBackward :: Ord a => a -> a -> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDeleteBackward :: forall a.
Ord a =>
a
-> a
-> UndirectedNeighbourMap a
-> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDeleteBackward a
from a
x (UndirectedNeighbourMap Map a (OneTwo a)
m) = case a -> Map a (OneTwo a) -> Maybe (OneTwo a)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup a
x Map a (OneTwo a)
m of
Maybe (OneTwo a)
Nothing -> Maybe (a, UndirectedNeighbourMap a)
forall a. Maybe a
Nothing
Just (One a
a) -> (a, UndirectedNeighbourMap a)
-> Maybe (a, UndirectedNeighbourMap a)
forall a. a -> Maybe a
Just (a
a, Map a (OneTwo a) -> UndirectedNeighbourMap a
forall a. Map a (OneTwo a) -> UndirectedNeighbourMap a
UndirectedNeighbourMap (a -> Map a (OneTwo a) -> Map a (OneTwo a)
forall k a. Ord k => k -> Map k a -> Map k a
M.delete a
x Map a (OneTwo a)
m))
Just (Two a
a a
b) ->
let (a
extract, a
keep)
| a
from a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
a = (a
a,a
b)
| Bool
otherwise = (a
b,a
a)
in (a, UndirectedNeighbourMap a)
-> Maybe (a, UndirectedNeighbourMap a)
forall a. a -> Maybe a
Just (a
extract, Map a (OneTwo a) -> UndirectedNeighbourMap a
forall a. Map a (OneTwo a) -> UndirectedNeighbourMap a
UndirectedNeighbourMap (a -> OneTwo a -> Map a (OneTwo a) -> Map a (OneTwo a)
forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert a
x (a -> OneTwo a
forall a. a -> OneTwo a
One a
keep) Map a (OneTwo a)
m))
lnmLookupDelete :: Ord a => a -> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDelete :: forall a.
Ord a =>
a
-> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDelete a
start UndirectedNeighbourMap a
lnm = case a
-> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
forall a.
Ord a =>
a
-> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDeleteForward a
start UndirectedNeighbourMap a
lnm of
Maybe (a, UndirectedNeighbourMap a)
Nothing -> Maybe (a, UndirectedNeighbourMap a)
forall a. Maybe a
Nothing
Just (a
target, UndirectedNeighbourMap a
lnm') -> case a
-> a
-> UndirectedNeighbourMap a
-> Maybe (a, UndirectedNeighbourMap a)
forall a.
Ord a =>
a
-> a
-> UndirectedNeighbourMap a
-> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDeleteBackward a
start a
target UndirectedNeighbourMap a
lnm' of
Maybe (a, UndirectedNeighbourMap a)
Nothing -> (a, UndirectedNeighbourMap a)
-> Maybe (a, UndirectedNeighbourMap a)
forall a. a -> Maybe a
Just (a
target, UndirectedNeighbourMap a
lnm')
Just (a
_xPointedToByNeighbour, UndirectedNeighbourMap a
lnm'') -> (a, UndirectedNeighbourMap a)
-> Maybe (a, UndirectedNeighbourMap a)
forall a. a -> Maybe a
Just (a
target, UndirectedNeighbourMap a
lnm'')
lnmArbitraryElement :: UndirectedNeighbourMap a -> Maybe a
lnmArbitraryElement :: forall a. UndirectedNeighbourMap a -> Maybe a
lnmArbitraryElement (UndirectedNeighbourMap Map a (OneTwo a)
m) = ((a, OneTwo a) -> a) -> Maybe (a, OneTwo a) -> Maybe a
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, OneTwo a) -> a
forall a b. (a, b) -> a
fst (Map a (OneTwo a) -> Maybe (a, OneTwo a)
forall k a. Map k a -> Maybe (k, a)
M.lookupMin Map a (OneTwo a)
m)
reassembleLines
:: (Ord point, Foldable f)
=> (line -> (point, point))
-> f line
-> [[point]]
reassembleLines :: forall point (f :: * -> *) line.
(Ord point, Foldable f) =>
(line -> (point, point)) -> f line -> [[point]]
reassembleLines line -> (point, point)
neighbour = (Seq point -> [point]) -> [Seq point] -> [[point]]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Seq point -> [point]
forall a. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList ([Seq point] -> [[point]])
-> (f line -> [Seq point]) -> f line -> [[point]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UndirectedNeighbourMap point -> [Seq point]
forall a. Ord a => UndirectedNeighbourMap a -> [Seq a]
extractAllTrajectories (UndirectedNeighbourMap point -> [Seq point])
-> (f line -> UndirectedNeighbourMap point)
-> f line
-> [Seq point]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (line -> (point, point)) -> f line -> UndirectedNeighbourMap point
forall (f :: * -> *) point line.
(Foldable f, Ord point) =>
(line -> (point, point)) -> f line -> UndirectedNeighbourMap point
buildUndirectedNeighbourMap line -> (point, point)
neighbour
buildUndirectedNeighbourMap :: (Foldable f, Ord point) => (line -> (point, point)) -> f line -> UndirectedNeighbourMap point
buildUndirectedNeighbourMap :: forall (f :: * -> *) point line.
(Foldable f, Ord point) =>
(line -> (point, point)) -> f line -> UndirectedNeighbourMap point
buildUndirectedNeighbourMap line -> (point, point)
neighbours = (line -> UndirectedNeighbourMap point)
-> f line -> UndirectedNeighbourMap point
forall m a. Monoid m => (a -> m) -> f a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap ((line -> UndirectedNeighbourMap point)
-> f line -> UndirectedNeighbourMap point)
-> (line -> UndirectedNeighbourMap point)
-> f line
-> UndirectedNeighbourMap point
forall a b. (a -> b) -> a -> b
$ \line
line ->
let (point
a,point
b) = line -> (point, point)
neighbours line
line
in Map point (OneTwo point) -> UndirectedNeighbourMap point
forall a. Map a (OneTwo a) -> UndirectedNeighbourMap a
UndirectedNeighbourMap ([(point, OneTwo point)] -> Map point (OneTwo point)
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [(point
a, point -> OneTwo point
forall a. a -> OneTwo a
One point
b), (point
b, point -> OneTwo point
forall a. a -> OneTwo a
One point
a)])
extractSingleTrajectoryPass
:: Ord a
=> UndirectedNeighbourMap a
-> a
-> Seq a
-> (UndirectedNeighbourMap a, Seq a)
UndirectedNeighbourMap a
lnm a
start Seq a
result
| Just (a
next, UndirectedNeighbourMap a
lnm') <- a
-> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
forall a.
Ord a =>
a
-> UndirectedNeighbourMap a -> Maybe (a, UndirectedNeighbourMap a)
lnmLookupDelete a
start UndirectedNeighbourMap a
lnm = UndirectedNeighbourMap a
-> a -> Seq a -> (UndirectedNeighbourMap a, Seq a)
forall a.
Ord a =>
UndirectedNeighbourMap a
-> a -> Seq a -> (UndirectedNeighbourMap a, Seq a)
extractSingleTrajectoryPass UndirectedNeighbourMap a
lnm' a
next (Seq a
result Seq a -> a -> Seq a
forall a. Seq a -> a -> Seq a
|> a
next)
| Bool
otherwise = (UndirectedNeighbourMap a
lnm, Seq a
result)
extractSingleTrajectory
:: Ord a
=> UndirectedNeighbourMap a
-> a
-> (UndirectedNeighbourMap a, Seq a)
UndirectedNeighbourMap a
nMap a
start =
let (UndirectedNeighbourMap a
nMapA, Seq a
trajectoryPass1) = UndirectedNeighbourMap a
-> a -> Seq a -> (UndirectedNeighbourMap a, Seq a)
forall a.
Ord a =>
UndirectedNeighbourMap a
-> a -> Seq a -> (UndirectedNeighbourMap a, Seq a)
extractSingleTrajectoryPass UndirectedNeighbourMap a
nMap a
start Seq a
forall a. Monoid a => a
mempty
(UndirectedNeighbourMap a
nMapB, Seq a
trajectoryPass2) = UndirectedNeighbourMap a
-> a -> Seq a -> (UndirectedNeighbourMap a, Seq a)
forall a.
Ord a =>
UndirectedNeighbourMap a
-> a -> Seq a -> (UndirectedNeighbourMap a, Seq a)
extractSingleTrajectoryPass UndirectedNeighbourMap a
nMapA a
start Seq a
forall a. Monoid a => a
mempty
in (UndirectedNeighbourMap a
nMapB, Seq a -> Seq a
forall a. Seq a -> Seq a
Seq.reverse Seq a
trajectoryPass2 Seq a -> Seq a -> Seq a
forall a. Semigroup a => a -> a -> a
<> a -> Seq a
forall a. a -> Seq a
Seq.singleton a
start Seq a -> Seq a -> Seq a
forall a. Semigroup a => a -> a -> a
<> Seq a
trajectoryPass1)
extractAllTrajectories :: Ord a => UndirectedNeighbourMap a -> [Seq a]
UndirectedNeighbourMap a
lnm
| Just a
start <- UndirectedNeighbourMap a -> Maybe a
forall a. UndirectedNeighbourMap a -> Maybe a
lnmArbitraryElement UndirectedNeighbourMap a
lnm =
let (UndirectedNeighbourMap a
lnm', Seq a
trajectory) = UndirectedNeighbourMap a -> a -> (UndirectedNeighbourMap a, Seq a)
forall a.
Ord a =>
UndirectedNeighbourMap a -> a -> (UndirectedNeighbourMap a, Seq a)
extractSingleTrajectory UndirectedNeighbourMap a
lnm a
start
in Seq a
trajectory Seq a -> [Seq a] -> [Seq a]
forall a. a -> [a] -> [a]
: UndirectedNeighbourMap a -> [Seq a]
forall a. Ord a => UndirectedNeighbourMap a -> [Seq a]
extractAllTrajectories UndirectedNeighbourMap a
lnm'
| Bool
otherwise = []