noncanonical

noncanonical, function

def process noncanonical(old: text, new: text): boolean

Returns true for edges (old, new) that should be removed so a canonical replacement can be assigned to every node.

Examples

Without grouping, the edges are evaluated as a single graph.

table Edges = with
  [| as Old, as New |]
  [| "a", "b" |]
  [| "b", "a" |]
  [| "x", "y" |]
  [| "y", "z" |]
  [| "z", "z" |]

Edges.Bad = noncanonical(Edges.Old, Edges.New)

show table "Noncanonical" with
  Edges.Old
  Edges.New
  Edges.Bad

This produces the following table:

Old New Bad
a b false
b a true
x y false
y z false
z z false

With by, independent graphs are evaluated per group.

table Edges = with
  [| as Old, as New, as Group |]
  [| "a", "b", "G1" |]
  [| "b", "a", "G1" |]
  [| "x", "y", "G2" |]
  [| "y", "z", "G2" |]
  [| "z", "z", "G2" |]

Edges.Bad = noncanonical(Edges.Old, Edges.New) by Edges.Group

show table "Noncanonical" with
  Edges.Group
  Edges.Old
  Edges.New
  Edges.Bad

This produces the following table:

Group Old New Bad
G1 a b false
G1 b a true
G2 x y false
G2 y z false
G2 z z false

Remarks

Use by to evaluate independent graphs per group. After filtering edges where noncanonical is true, canonical can be called safely on the remaining edges. Omitting by treats all edges as part of the same graph.

See also

User Contributed Notes
0 notes + add a note