adds lookup on interface -> lookup_node lookup_edge
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Fri, 17 Jan 2025 05:01:09 +0000 (05:01 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Fri, 17 Jan 2025 05:01:09 +0000 (05:01 +0000)
developer/deprecated/DirectedGraph.java
developer/deprecated/hold/Ariadne_DirectedGraph.java
developer/deprecated/temp.java
developer/example/GraphCycleCFinder/TM_SR_ND_Depth.java
developer/example/GraphIndexTree/Graph.java
developer/example/GraphIndexTree/four_down_four_across_CLI.java
developer/javacđź–‰/Ariadne_Graph.java
documentđź–‰/todo.txt
tester/deprecated/Test_GraphDirectedAcyclic.java
tester/deprecated/Test_Graph_0.java

index c8b2420..077c588 100644 (file)
@@ -100,7 +100,7 @@ public class Ariadne_GraphDirectedAcyclic extends Ariadne_Graph{
       Ariadne_LabelList undefined_node_list = new Ariadne_LabelList();
       for (int i = cycle_i0; i <= cycle_n; i++){
         Ariadne_Label node_label = left_path.get(i);
-        Ariadne_Node node = super.lookup(node_label);
+        Ariadne_Node node = super.lookup_node(node_label);
         if(node != null){
           node.mark(new Ariadne_Token("cycle_member"));
         } else{
@@ -139,7 +139,7 @@ public class Ariadne_GraphDirectedAcyclic extends Ariadne_Graph{
         }
 
         Ariadne_Label it_node_label = path_stack.get(path_stack.size() - 1).get(0);
-        Ariadne_Node it_node = super.lookup(it_node_label);
+        Ariadne_Node it_node = super.lookup_node(it_node_label);
         if(it_node == null){
           ret_value.add(new Ariadne_Token("undefined_node"));
           return ret_value;
@@ -216,8 +216,8 @@ public class Ariadne_GraphDirectedAcyclic extends Ariadne_Graph{
   }
 
   @Override
-  public Ariadne_Node lookup(Ariadne_Label node_label, boolean verbose){
-    Ariadne_Node node = super.lookup(node_label, verbose);
+  public Ariadne_Node lookup_node(Ariadne_Label node_label, boolean verbose){
+    Ariadne_Node node = super.lookup_node(node_label, verbose);
     if(node != null && node.has_mark(new Ariadne_Token("cycle_member"))){
       if(verbose){
         System.out.println("GraphDirectedAcyclic.lookup:: Node is part of a cycle, not returned: " + node_label);
@@ -227,8 +227,8 @@ public class Ariadne_GraphDirectedAcyclic extends Ariadne_Graph{
     return node;
   }
 
-  public Ariadne_Node lookup(Ariadne_Label node_label){
-    return lookup(node_label, this.debug);
+  public Ariadne_Node lookup_node(Ariadne_Label node_label){
+    return lookup_node(node_label, this.debug);
   }
 
 }
index 941d935..e708f39 100644 (file)
@@ -20,7 +20,7 @@ public class Ariadne_Graph{
 
   public Ariadne_StepRightMachine<Ariadne_Node> start();
   public Ariadne_StepRightMachine<Ariadne_Node> traverse();
-  public Ariadne_Node lookup(String label);
+  public Ariadne_Node lookup_node(String label);
 
 
 }
index 635708a..6bb5d87 100644 (file)
@@ -48,7 +48,7 @@ public class IndexTree_TM_SR_ND_Diagonal extends Ariadne_TM_SR_ND_Label {
     IndexTree_Label root_label = IndexTree_Label.root();
     read_list.add( root_label );
 
-    IndexTree_Node root_node = lookup( root_label );
+    IndexTree_Node root_node = lookup_node( root_label );
     breadth_srm.mount( root_node.neighbor() );
 
     if( breadth_srm.can_read() ){
@@ -56,7 +56,7 @@ public class IndexTree_TM_SR_ND_Diagonal extends Ariadne_TM_SR_ND_Label {
     }
   }
 
-  private IndexTree_Node lookup( Ariadne_Label label ){
+  private IndexTree_Node lookup_node( Ariadne_Label label ){
     return IndexTree_Node.make( (IndexTree_Label)label );
   }
 
@@ -74,7 +74,7 @@ public class IndexTree_TM_SR_ND_Diagonal extends Ariadne_TM_SR_ND_Label {
       Ariadne_Label label = list_of__unopened_node.remove( 0 );
 
       // Retrieve the node using lookup
-      IndexTree_Node node = lookup( label );
+      IndexTree_Node node = lookup_node( label );
 
       // Mount a new breadth-first TM_SR_ND for children
       breadth_srm.mount( node.neighbor() );
@@ -97,7 +97,7 @@ public class IndexTree_TM_SR_ND_Diagonal extends Ariadne_TM_SR_ND_Label {
         Ariadne_Label label = child_list.remove( 0 );
         read_list.add( label );
 
-        IndexTree_Node node = lookup( label );
+        IndexTree_Node node = lookup_node( label );
         breadth_srm.mount( node.neighbor() );
 
         if( breadth_srm.can_read() ){
index ea3abcd..4c4dbf7 100644 (file)
@@ -50,7 +50,7 @@ import com.ReasoningTechnology.Ariadne.Ariadne_Label;
 import com.ReasoningTechnology.Ariadne.Ariadne_TM_SR_ND_Array;
 import com.ReasoningTechnology.Ariadne.Ariadne_TM_SR_ND_List;
 
-class TM_SR_ND_Depth extends Ariadne_TM_SR_ND{
+class TM_SR_ND_Depth extends Ariadne_TM_SR_ND<Label>{
 
   // static
   //
@@ -67,7 +67,7 @@ class TM_SR_ND_Depth extends Ariadne_TM_SR_ND{
   // instance data
   //
   protected Ariadne_Graph graph = null;
-  protected List<Ariadne_TM_SR_ND> context_path = new ArrayList<>();
+  protected List<Ariadne_TM_SR_ND<Label>> context_path = new ArrayList<>();
   protected Ariadne_Label cycle_node_label = null;
 
   // constructor
@@ -97,7 +97,7 @@ class TM_SR_ND_Depth extends Ariadne_TM_SR_ND{
     Ariadne_TM_SR_ND child_srtm = null;
     Ariadne_Label path_node_label = null;
 
-    // context_path is known not to be  empty, so can_read() is true
+    // context_path is known not to be empty, so can_read() is true
     do{
       child_srtm = context_path_srtm.read();
       path_node_label = child_srtm.read();
@@ -125,7 +125,7 @@ class TM_SR_ND_Depth extends Ariadne_TM_SR_ND{
     Ariadne_Node path_node = null;
     boolean is_leaf_node = false;
     do{
-      path_node = graph.lookup(path_node_label);
+      path_node = graph.lookup_node(path_node_label);
       if(path_node == null){
         System.out.println
           (
index 67f7501..83f24ac 100644 (file)
@@ -14,7 +14,7 @@ public class Graph extends Ariadne_Graph<Label>{
   }
 
   // no override, this graph does not lookup Ariadne_Label, only Label
-  @Override public Node lookup(Label label){
+  @Override public Node lookup_node(Label label){
     return Node.make(label);
   }
 
index 4065dfa..166ee65 100644 (file)
@@ -19,7 +19,7 @@ public class four_down_four_across_CLI{
     // Descend 3 more levels
     int i = 1;
     do{
-      node = graph.lookup(label);
+      node = graph.lookup_node(label);
       child_srm = node.neighbor();
       label = child_srm.read();
       System.out.println("Descended to: " + label.toString());
index 8a9420d..2d53437 100644 (file)
@@ -23,8 +23,13 @@ public class Ariadne_Graph<LT extends Ariadne_Label>{
     throw new UnsupportedOperationException("Ariadne_Graph::start.");
   }
 
-  public Ariadne_Node lookup(LT label){
+  public Ariadne_Node lookup_node(LT label){
     throw new UnsupportedOperationException("Ariadne_Graph::lookup.");
   }
 
+  public Ariadne_Node lookup_edge(LT label ,LT label){
+    throw new UnsupportedOperationException("Ariadne_Graph::lookup.");
+  }
+
+
 }
index 1b081de..521ee5d 100644 (file)
@@ -33,3 +33,6 @@ part of the TestBench.
   Java, it is not clear that benefits of having a 'cleaner' implementation would
   justify the work.
 
+4 add hash map to graph, lookup on node label pairs to find edge properties.
+
+5. append() method for TM_SR_ND.
index 04ff7ed..6de1862 100644 (file)
@@ -113,7 +113,7 @@ public class Test_GraphDirectedAcyclic {
 
       Ariadne_GraphDirectedAcyclic graph = new Ariadne_GraphDirectedAcyclic(nodeMap, new Ariadne_ProductionList(), new Ariadne_LabelList());
 
-      Ariadne_Node foundNode = graph.lookup(label, true);
+      Ariadne_Node foundNode = graph.lookup_node(label, true);
       conditions[i++] = foundNode == node; // Expect to find the node
 
       return Mosaic_Util.all(conditions);
index 4c8dc6a..755c868 100644 (file)
@@ -36,8 +36,8 @@ public class Test_Graph_0 {
       Graph graph = new Graph(nodeMap, new ProductionList());
 
       // Test lookup for existing and non-existing labels
-      conditions[i++] = graph.lookup(label1, true) == node1;
-      conditions[i++] = graph.lookup(new Label("nonexistent"), true) == null;
+      conditions[i++] = graph.lookup_node(label1, true) == node1;
+      conditions[i++] = graph.lookup_node(new Label("nonexistent"), true) == null;
 
       io.clear_buffers(); // Clear after each case
       return MU.all(conditions);
@@ -57,7 +57,7 @@ public class Test_Graph_0 {
       Graph graph = new Graph(nodeMap, new ProductionList());
 
       // Perform lookup without verbosity
-      Node result = graph.lookup(label, false);
+      Node result = graph.lookup_node(label, false);
       conditions[i++] = result == node;  // Expected to find node without verbose output
 
       return MU.all(conditions);