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

NetSpider.Weaver

Description

Since: 0.4.2.0

Synopsis

Type

data Weaver n na la Source #

Weaver is an on-memory builder for snapshot graphs. It builds a SnapshotGraph from FoundNodes without using an external graph database.

Instances

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

Defined in NetSpider.Weaver

Methods

(==) :: Weaver n na la -> Weaver n na la -> Bool #

(/=) :: Weaver n na la -> Weaver n na la -> Bool #

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

Defined in NetSpider.Weaver

Methods

showsPrec :: Int -> Weaver n na la -> ShowS #

show :: Weaver n na la -> String #

showList :: [Weaver n na la] -> ShowS #

Construction

newWeaver :: FoundNodePolicy n na -> Weaver n na la Source #

Make a new Weaver.

The FoundNodePolicy controls the behavior of addFoundNode. If it's policyOverwrite, Weaver maintains only the FoundNode with the latest timestamp for each node. If it's policyAppend, Weaver maintains all FoundNodes added.

Add FoundNode

addFoundNode :: (Eq n, Hashable n) => FoundNode n na la -> Weaver n na la -> Weaver n na la Source #

Add a FoundNode to the Weaver. See also newWeaver.

markAsVisited :: (Eq n, Hashable n) => n -> Weaver n na la -> Weaver n na la Source #

Mark the node ID as visited in the Weaver without any FoundNode. If there is already some FoundNode for the node ID, this function does nothing.

Query

getSnapshot :: (Ord n, Hashable n, Show n) => LinkSampleUnifier n na fla sla -> Weaver n na fla -> SnapshotGraph n na sla Source #

Make SnapshotGraph from the current Weaver.

The SnapshotGraph is constructed from all FoundNodes added to the Weaver so far.

getSnapshot' :: (Ord n, Hashable n, Show n) => LinkSampleUnifier n na fla sla -> Weaver n na fla -> (SnapshotGraph n na sla, [LogLine]) Source #

Same as getSnapshot, but it also returns logs.

isVisited :: (Eq n, Hashable n) => n -> Weaver n na la -> Bool Source #

Returns True if the node ID is already visited in the Weaver.

A visited node is the one that has at least one FoundNode added, or on which markAsVisited has executed.

getFoundNodes :: (Eq n, Hashable n) => n -> Weaver n na la -> Maybe [FoundNode n na la] Source #

Get the FoundNodes for the given node ID kept in Weaver.

It returns Nothing if the node ID is not visited. It returns an empty list if the node ID is visited (by markAsVisited), but doesn't have any FoundNode.

getBoundaryNodes :: (Eq n, Hashable n) => Weaver n na fla -> [n] Source #

Get boundary nodes from the Weaver.

A boundary node is a node that has been observed as a target of some links but not visited yet. This function returns the set of unique boundary nodes.

Misc.

visitAllBoundaryNodes :: (Eq n, Hashable n) => Weaver n na fla -> Weaver n na fla Source #

(Basically for testing): run markAsVisited on all boundary nodes.