@@ -17,9 +17,9 @@ public bool Equals(Graph<T> other) =>
1717 Value . Equals ( other . Value ) && Children . SequenceEqual ( other . Children ) ;
1818}
1919
20- public class Crumb < T >
20+ public class GraphCrumb < T >
2121{
22- public Crumb ( T value , IEnumerable < Graph < T > > left , IEnumerable < Graph < T > > right )
22+ public GraphCrumb ( T value , IEnumerable < Graph < T > > left , IEnumerable < Graph < T > > right )
2323 {
2424 Value = value ;
2525 Left = left ;
@@ -31,16 +31,16 @@ public Crumb(T value, IEnumerable<Graph<T>> left, IEnumerable<Graph<T>> right)
3131 public IEnumerable < Graph < T > > Right { get ; }
3232}
3333
34- public class Zipper < T >
34+ public class GraphZipper < T >
3535{
36- public Zipper ( Graph < T > focus , IEnumerable < Crumb < T > > crumbs )
36+ public GraphZipper ( Graph < T > focus , IEnumerable < GraphCrumb < T > > crumbs )
3737 {
3838 Focus = focus ;
3939 Crumbs = crumbs ;
4040 }
4141
4242 public Graph < T > Focus { get ; }
43- public IEnumerable < Crumb < T > > Crumbs { get ; }
43+ public IEnumerable < GraphCrumb < T > > Crumbs { get ; }
4444}
4545
4646public static class Pov
@@ -54,49 +54,49 @@ public static Graph<T> FromPOV<T>(T value, Graph<T> graph) where T : IComparable
5454 public static IEnumerable < T > TracePathBetween < T > ( T value1 , T value2 , Graph < T > graph ) where T : IComparable
5555 => ZipperToPath ( FindNode ( value2 , GraphToZipper ( FromPOV ( value1 , graph ) ) ) ) ;
5656
57- private static Zipper < T > GraphToZipper < T > ( Graph < T > graph )
57+ private static GraphZipper < T > GraphToZipper < T > ( Graph < T > graph )
5858 {
5959 if ( graph == null )
6060 return null ;
6161
62- return new Zipper < T > ( graph , Enumerable . Empty < Crumb < T > > ( ) ) ;
62+ return new GraphZipper < T > ( graph , Enumerable . Empty < GraphCrumb < T > > ( ) ) ;
6363 }
6464
65- private static IEnumerable < T > ZipperToPath < T > ( Zipper < T > zipper )
65+ private static IEnumerable < T > ZipperToPath < T > ( GraphZipper < T > zipper )
6666 {
6767 if ( zipper == null )
6868 return null ;
6969
7070 return zipper . Crumbs . Select ( c => c . Value ) . Reverse ( ) . Concat ( new [ ] { zipper . Focus . Value } ) ;
7171 }
7272
73- private static Zipper < T > GoDown < T > ( Zipper < T > zipper )
73+ private static GraphZipper < T > GoDown < T > ( GraphZipper < T > zipper )
7474 {
7575 if ( zipper == null || ! zipper . Focus . Children . Any ( ) )
7676 return null ;
7777
7878 var focus = zipper . Focus ;
7979 var children = focus . Children ;
8080
81- var newCrumb = new Crumb < T > ( focus . Value , Enumerable . Empty < Graph < T > > ( ) , children . Skip ( 1 ) ) ;
81+ var newCrumb = new GraphCrumb < T > ( focus . Value , Enumerable . Empty < Graph < T > > ( ) , children . Skip ( 1 ) ) ;
8282
83- return new Zipper < T > ( children . First ( ) , new [ ] { newCrumb } . Concat ( zipper . Crumbs ) ) ;
83+ return new GraphZipper < T > ( children . First ( ) , new [ ] { newCrumb } . Concat ( zipper . Crumbs ) ) ;
8484 }
8585
86- private static Zipper < T > GoRight < T > ( Zipper < T > zipper )
86+ private static GraphZipper < T > GoRight < T > ( GraphZipper < T > zipper )
8787 {
8888 if ( zipper == null || ! zipper . Crumbs . Any ( ) || ! zipper . Crumbs . First ( ) . Right . Any ( ) )
8989 return null ;
9090
9191 var crumbs = zipper . Crumbs ;
9292 var firstCrumb = crumbs . First ( ) ;
9393
94- var newCrumb = new Crumb < T > ( firstCrumb . Value , firstCrumb . Left . Concat ( new [ ] { zipper . Focus } ) , firstCrumb . Right . Skip ( 1 ) ) ;
94+ var newCrumb = new GraphCrumb < T > ( firstCrumb . Value , firstCrumb . Left . Concat ( new [ ] { zipper . Focus } ) , firstCrumb . Right . Skip ( 1 ) ) ;
9595
96- return new Zipper < T > ( firstCrumb . Right . First ( ) , new [ ] { newCrumb } . Concat ( crumbs . Skip ( 1 ) ) ) ;
96+ return new GraphZipper < T > ( firstCrumb . Right . First ( ) , new [ ] { newCrumb } . Concat ( crumbs . Skip ( 1 ) ) ) ;
9797 }
9898
99- private static Zipper < T > FindNode < T > ( T value , Zipper < T > zipper )
99+ private static GraphZipper < T > FindNode < T > ( T value , GraphZipper < T > zipper )
100100 where T : IComparable
101101 {
102102 if ( zipper == null || zipper . Focus . Value . CompareTo ( value ) == 0 )
@@ -105,7 +105,7 @@ private static Zipper<T> FindNode<T>(T value, Zipper<T> zipper)
105105 return FindNode ( value , GoDown ( zipper ) ) ?? FindNode ( value , GoRight ( zipper ) ) ;
106106 }
107107
108- private static Graph < T > ChangeParent < T > ( Zipper < T > zipper )
108+ private static Graph < T > ChangeParent < T > ( GraphZipper < T > zipper )
109109 {
110110 if ( zipper == null )
111111 return null ;
@@ -116,7 +116,7 @@ private static Graph<T> ChangeParent<T>(Zipper<T> zipper)
116116 var firstCrumb = zipper . Crumbs . First ( ) ;
117117 var focus = zipper . Focus ;
118118
119- var newZipper = new Zipper < T > ( CreateGraph ( firstCrumb . Value , firstCrumb . Left . Concat ( firstCrumb . Right ) ) , zipper . Crumbs . Skip ( 1 ) ) ;
119+ var newZipper = new GraphZipper < T > ( CreateGraph ( firstCrumb . Value , firstCrumb . Left . Concat ( firstCrumb . Right ) ) , zipper . Crumbs . Skip ( 1 ) ) ;
120120 var parentGraph = ChangeParent ( newZipper ) ;
121121
122122 var ys = focus . Children . Concat ( new [ ] { parentGraph } ) ;
0 commit comments