Class: Matching

Matching

A geometric matching: - a "set" of points - a "set" of segments on these points The set of points may be shared with other linked matching.

Constructor

new Matching(linkedMatching)

Construct a Matching. If linkedMatching !== null then shared points with it.
Parameters:
Name Type Default Description
linkedMatching null | Matching null
Source:

Members

linkedMatchings

Returns the ordonned sequence of linked matchings.
Source:

numberPerfectMatchingsIfCalculated

If is already calculated or if it easy to calculate then returns the exact number of perfect matchings for theses points, else returns null.
Source:

points

Returns the ordonned sequence of points.
Source:

segments

Returns the sequence of segments.
Source:

Methods

allPerfectMatchings(disjointMatching, compatibleMatching) → {Array}

Returns all possible perfect matchings with the points of this matching. If disjointMatching then keep only perfect matching disjoint with this matching. If compatibleMatching then keep only perfect matching disjoint with this matching. FIXME! Naive algorithm. Implement iterative building?
Parameters:
Name Type Description
disjointMatching Boolean
compatibleMatching Boolean
Source:
Returns:
Array of Matching
Type
Array

allPerfectMatchingsUppedBound() → {Number}

Returns an upper bound of number of all possible perfect matchings with the points of this matching.
Source:
Returns:
Type
Number

canonical() → {Matching}

Returns the canonical perfect matching corresponding to these points.
Source:
Returns:
Type
Matching

clear()

Empty sets of points and segments, and intermediary linked matchings.
Source:

clearIfModifyPoints()

Reset some data when add or remove point.
Source:

clearIntermediaryLinkedMatchings()

Remove all intermediary linked matchings.
Source:

commonSegments(other) → {Set}

Returns a set of segments in common between this matching and other.
Parameters:
Name Type Description
other Matching
Source:
Returns:
Set of Segment
Type
Set

commonSegmentsWithConsecutiveMatchings() → {Set}

Returns a set of segments in common between this matching and previous or next one.
Source:
Returns:
Set of Segment
Type
Set

isCanonical() → {boolean}

Returns true iff the matching is the canonical perfect matching.
Source:
Returns:
Type
boolean

isCompatible(other) → {boolean}

Returns true iff matching and other are compatible (union have no intersection segments, without their endpoints).
Parameters:
Name Type Description
other Matching
Source:
Returns:
Type
boolean

isDisjoint(other) → {boolean}

Returns true iff matching and other are disjoint (no common segments).
Parameters:
Name Type Description
other Matching
Source:
Returns:
Type
boolean

isEquals(other) → {boolean}

Returns true iff are equals matchings (same points and same segments).
Parameters:
Name Type Description
other Matching
Source:
Returns:
Type
boolean

isolatedPoints() → {Set}

Returns a set of all points without segment.
Source:
Returns:
Set of points
Type
Set

isPerfect() → {boolean}

Returns true iff the matching is perfect (each point is degree 1)
Source:
Returns:
Type
boolean

isVerticalHorizontal() → {boolean}

Returns true iff all segment are vertical or horizontal.
Source:
Returns:
Type
boolean

linkedMatchingsIndex() → {integer}

Returns the index of this matching in the sequence of linked matchings.
Source:
Returns:
>= 0
Type
integer

matchingsToString() → {String}

Returns all informations of all linked matchings in a string : # points x_0, y_0 ... x_{n-1}, y_{n-1} # matching # segment for first matching index point a - index point b ... ... # segment for last matching index point a - index point b ... Warning! All point coordinates are rounded to integers.
Source:
Returns:
Type
String

nearestPoint(point) → {Point|null}

Returns the nearest point of the matching or null if no nearest point.
Parameters:
Name Type Description
point Point
Source:
Returns:
Type
Point | null

pointAdd(point)

Add a point.
Parameters:
Name Type Description
point Point (not already in the matching)
Source:

pointIsInMatching(point) → {boolean}

Returns true iff point is a point of the matching.
Parameters:
Name Type Description
point Point
Source:
Returns:
Type
boolean

pointRemove(point, removeInLinkedMatchings)

Remove the existing point. If there is a segment with this point then remove this segment. If removeInLinkedMatchings then remove also segments in all linked matchings.
Parameters:
Name Type Default Description
point Point (must be in the matching)
removeInLinkedMatchings boolean true
Source:

pointsIndices() → {Map}

Returns an associative table Point: (it index in the sequence of points).
Source:
Returns:
Point:(integer >= 0)
Type
Map

properIntersectSegments(other) → {Set}

Returns a set of segments that intersect (without their endpoints) one of other.
Parameters:
Name Type Description
other Matching
Source:
Returns:
Set of Segment
Type
Set

properIntersectSegmentsWithConsecutiveMatchings() → {Set}

Returns a set of segments that intersect (without their endpoints) one of previous or next matching.
Source:
Returns:
Set of Segment
Type
Set

segmentAdd(segment)

Add a segment.
Parameters:
Name Type Description
segment Segment (not already in the matching)
Source:

segmentIsInMatching(segment) → {boolean}

Returns true iff segment is a segment of the matching.
Parameters:
Name Type Description
segment Segment
Source:
Returns:
Type
boolean

segmentIsIntersect(segment) → {boolean}

Returns true iff segment intersect (*with* their endpoints) a segment of the matching.
Parameters:
Name Type Description
segment Segment
Source:
Returns:
Type
boolean

segmentRemove(segment)

Remove the existing segment.
Parameters:
Name Type Description
segment Segment (must be in the matching)
Source:

setCanonical() → {Matching}

Set segments to be the canonical perfect matching corresponding to these points.
Source:
Returns:
Type
Matching

setPerfectMatchings(disjointMatching, compatibleMatching)

Calculate all possible perfect matchings with the points of this matching and set this list as the linked matchings. If disjointMatching then keep only perfect matching disjoint with this matching. If compatibleMatching then keep only perfect matching disjoint with this matching.
Parameters:
Name Type Description
disjointMatching Boolean
compatibleMatching Boolean
Source:

setTransformation(disjointTransformation) → {boolean}

Set the list of linked matchings to be a transformation (a list of perfect matchings two to two compatible) from this matching to the last linked matching. If disjointTransformation then search a disjoint transformation. Returns true if a transformation was found, else return false. The two utmost matchings must be perfect and different. Warning! Only transformations of length 2 and 3 are implemented. FIXME! Naive algorithm that build before all perfect matchings and try possibilities.
Parameters:
Name Type Description
disjointTransformation Boolean
Source:
Returns:
Type
boolean

shuffleSegments() → {Matching}

Set segments at random to be a perfect matching corresponding to these points.
Source:
Returns:
Type
Matching