net-spider-0.4.3.5: A graph database middleware to maintain a time-varying graph.
MaintainerToshio Ito <debug.ito@gmail.com>
Safe HaskellNone
LanguageHaskell2010

NetSpider.Unify

Description

 
Synopsis

Types

type LinkSampleUnifier n na fla sla = SnapshotNode n na -> SnapshotNode n na -> [LinkSample n fla] -> WriterLoggingM [LinkSample n sla] Source #

Function to unify LinkSamples collected for the given pair of nodes and return LinkSample per physical link. The returned LinkSamples will be directly converted to SnapshotLinks in the snapshot graph.

This function has a number of important roles during construction of the snapshot graph.

  • Because a link can be observed from both of its end nodes, there can be multiple LinkSamples for one physical link. This function is supposed to return one reasonable link sample for the physical link from those input link samples.
  • There can be multiple physical links for a given pair of nodes, but the Spider has no way to distinguish them. So, this function is supposed to distinguish LinkSamples for different physical links, and return one or more LinkSamples, each of which corresponds to a physical link.
  • Sometimes a link is found by one end node but not found by the other end node. Should Spider treats the link is available or not? This function is supposed to answer that question by returning non-empty result (if the link is available) or empty result (if the link is not available.)
  • Sometimes it is natural to have different data models of link attributes for FoundLinks (fla) and for SnapshotLinks (sla). For example, when you want to combine link attributes obtained from both of the end nodes to make the link attributes of SnapshotLink. This function is supposed to convert the link attribute type.

data LinkSample n la Source #

LinkSample is an intermediate type between FoundLink and SnapshotLink. LinkSamples are collected from the history graph, and are unified into SnapshotLinks.

Instances

Instances details
(Eq n, Eq la) => Eq (LinkSample n la) Source # 
Instance details

Defined in NetSpider.Unify

Methods

(==) :: LinkSample n la -> LinkSample n la -> Bool #

(/=) :: LinkSample n la -> LinkSample n la -> Bool #

(Ord n, Ord la) => Ord (LinkSample n la) Source # 
Instance details

Defined in NetSpider.Unify

Methods

compare :: LinkSample n la -> LinkSample n la -> Ordering #

(<) :: LinkSample n la -> LinkSample n la -> Bool #

(<=) :: LinkSample n la -> LinkSample n la -> Bool #

(>) :: LinkSample n la -> LinkSample n la -> Bool #

(>=) :: LinkSample n la -> LinkSample n la -> Bool #

max :: LinkSample n la -> LinkSample n la -> LinkSample n la #

min :: LinkSample n la -> LinkSample n la -> LinkSample n la #

(Show n, Show la) => Show (LinkSample n la) Source # 
Instance details

Defined in NetSpider.Unify

Methods

showsPrec :: Int -> LinkSample n la -> ShowS #

show :: LinkSample n la -> String #

showList :: [LinkSample n la] -> ShowS #

type LinkSampleID n = Pair n Source #

Link ID of the LinkSample. It's the Pair of lsSubjectNode and lsTargetNode.

toLinkSamples :: FoundNode n na la -> [LinkSample n la] Source #

Make LinkSamples from FoundLinks in FoundNode.

Since: 0.4.2.0

Standard unifiers

unifyToOne :: (Eq n, Show n) => LinkSampleUnifier n na la la Source #

Unify LinkSamples to one. This is the sensible unifier if there is at most one physical link for a given pair of nodes.

unifyToMany Source #

Arguments

:: (Eq n, Show n, Ord lsid) 
=> (LinkSample n fla -> lsid)

Getter of the link sub-ID

-> LinkSampleUnifier n na fla fla 

Unify LinkSamples to possibly multiple samples. The input samples are partitioned to groups based on the link sub-ID, defined by the given getter function. Each group represents one of the final samples.

unifyStd :: (Eq n, Show n, Ord lsid) => UnifyStdConfig n na fla sla lsid -> LinkSampleUnifier n na fla sla Source #

The standard unifier. This unifier does the following.

  1. It partitions LinkSamples based on their link sub-IDs. The link sub-ID is defined by makeLinkSubId function. Each link sub-ID corresponds to a physical link.
  2. For each partition, LinkSamples are merged to one using mergeSamples function.
  3. After merge, the link is checked against its end nodes. If negatesLinkSample returns True for either of the end nodes, the link is removed from the final result.

data UnifyStdConfig n na fla sla lsid Source #

Configuration of unifyStd. See unifyStd for detail.

Constructors

UnifyStdConfig 

Fields

defUnifyStdConfig :: Eq n => UnifyStdConfig n na fla fla () Source #

Default of UnifyStdConfig.

Building blocks

latestLinkSample :: [LinkSample n la] -> Maybe (LinkSample n la) Source #

Get the LinkSample that has the latest (biggest) timestamp.

defNegatesLinkSample :: Eq n => SnapshotNode n na -> LinkSample n la -> Bool Source #

Default of negatesLinkSample. This function returns True if all of the following conditions are met.

If the above conditions are met, it implies that the LinkSample is found by the other end node, but the given SnapshotNode does not find it. This is possibly because the link has just disappeared, so the link should be negated.