drepr.planning.drepr_model_alignments#
Classes
|
THE FOLLOWING CODE IS ADAPTED FROM: https://docs.rs/petgraph/0.4.13/src/petgraph/visit/traversal.rs.html#38-43 so that DFS also yield the parent node |
|
|
|
A mapping for storing the visited status for NodeId N. |
- class DReprModelAlignments(desc: 'DRepr', aligns: 'dict[tuple[AttrId, AttrId], list[Alignment]]')[source]#
Bases:
object- Parameters:
- aligns: dict[tuple[str, str], list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]]#
- static create(desc: DRepr) DReprModelAlignments[source]#
Infer all possible alignments from the model.
- Parameters:
desc (DRepr) –
- Return type:
- get_alignments(source: str, target: str) list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]][source]#
- Parameters:
- Return type:
list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]
- infer_subject(attrs: list[str]) list[str][source]#
Find all attributes that can be the subject of these attributes
The subject must has one to one mapping to all attrs and: (1) have no missing path (2) have missing path, but the missing path is the same for all attrs.
has higher priority than (2).
- infer_func(xid: str, yid: str, zid: str) Optional[list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]][source]#
Infer an alignment function of xid and zid given alignments between (xid, yid) and (yid, zid)
If there is only one way to join values of xid and zid, then the chain join will be the correct one
- Parameters:
- Return type:
Optional[list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]]
- estimate_cardinality(aligns: list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]) Cardinality[source]#
- Parameters:
aligns (list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]) –
- Return type:
- optimize_chained_alignments(aligns: list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]) list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]][source]#
- Parameters:
aligns (list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]) –
- Return type:
list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]
- static auto_align(source: Attr, target: Attr) Optional[Union[RangeAlignment, IdenticalAlign]][source]#
- Parameters:
- Return type:
- score_alignment(align: Union[RangeAlignment, ValueAlignment, IdenticalAlign, AutoAlignment]) int[source]#
Score an alignment function so we can justify if an alignment is new/better or not. Lower score is better.
- Parameters:
align (Union[RangeAlignment, ValueAlignment, IdenticalAlign, AutoAlignment]) –
- Return type:
- class CustomedDfs(stack: list[tuple[str, str]], discovered: VisitMap)[source]#
Bases:
objectTHE FOLLOWING CODE IS ADAPTED FROM: https://docs.rs/petgraph/0.4.13/src/petgraph/visit/traversal.rs.html#38-43 so that DFS also yield the parent node
Visit nodes of a graph in a depth-first-search (DFS) emitting nodes in preorder (when they are first discovered).
The traversal starts at a given node and only traverses nodes reachable from it.
Dfs is not recursive.
Dfs does not itself borrow the graph, and because of this you can run a traversal over a graph while still retaining mutable access to it, if you use it like the following example:
``` use petgraph::Graph; use petgraph::visit::Dfs;
let mut graph = Graph::<_,()>::new(); let a = graph.add_node(0);
let mut dfs = Dfs::new(&graph, a); while let Some(nx) = dfs.next(&graph) {
// we can access graph mutably here still graph[nx] += 1;
}
Note: The algorithm may not behave correctly if nodes are removed during iteration. It may not necessarily visit added nodes or edges.
- static empty() CustomedDfs[source]#
Create a new Dfs using the graph’s visitor map, and no stack.
- Return type:
- static from_graph(graph: RetworkXStrDiGraph, start: str) CustomedDfs[source]#
Create a new Dfs, using the graph’s visitor map, and put start in the stack of nodes to visit.
- Parameters:
graph (RetworkXStrDiGraph) –
start (str) –
- Return type: