diff options
author | JSDurand <mmemmew@gmail.com> | 2023-01-05 10:24:39 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2023-01-05 10:24:39 +0800 |
commit | 7dd4935230e303aef8d295d992239d59d95b32d7 (patch) | |
tree | 486104820b5f3701518c1030a0393a5cef428cb9 /graph/src/lib.rs | |
parent | bdbd4b4dc21af09711c97d3f903877443199af06 (diff) |
singly labelled graphs
Now I have a new type of labelled graphs, which can index vertices by
labels, but not index edges by labels. The biggest difference is that
I do not have to keep a hashmap of edge targets by labels, and I do
not have to guard against the duplication of nodes with the same set
of edges. I guard against nodes with the same label, though.
Also, in this graph, both vertices and edges have one label at a time,
whereas in the previous labelled graph there can be a multitude of
edges between the same source and target nodes, but with different
labels.
Now it remains to test this type of graphs, and to think through how
we attach forest fragments to nondeterministic finite automata edges,
and how to join forest fragments together while skipping nullable
edges, in order to finish the "compilation" part.
Diffstat (limited to 'graph/src/lib.rs')
-rw-r--r-- | graph/src/lib.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/graph/src/lib.rs b/graph/src/lib.rs index d4f6d7c..79f9646 100644 --- a/graph/src/lib.rs +++ b/graph/src/lib.rs @@ -239,11 +239,20 @@ pub trait LabelGraph<T: GraphLabel>: Graph { Self: 'a, T: 'a; + /// Query the graph for a label, and return the node index if + /// found. + /// + /// The default implementation always returns `None`. + #[inline] + fn query_label(&self, _label: T) -> Option<usize> { + None + } + #[inline] /// Return the label of a vertex or an error if the node is /// invalid. /// - /// The default implementation always returns None for a valid + /// The default implementation always returns `None` for a valid /// node. fn vertex_label(&self, node_id: usize) -> Result<Option<T>, Error> { if self.has_node(node_id) { |