dgld.models.SCAN.model

Structural Clustering Algorithm for Networks

class dgld.models.SCAN.model.SCAN(eps=0.5, mu=2)[source]

Bases: Module

SCAN (Structural Clustering Algorithm for Networks).

Parameters
  • eps (float, optional) – Neighborhood threshold. Default: .5.

  • mu (int, optional) – Minimal size of clusters. Default: 2.

Examples

>>> from dgld.models.SCAN import SCAN
>>> model = SCAN()
>>> model.fit(g)
>>> result = model.predict(g)
eps_neighborhood(v)[source]

found eps-neighbors list

Parameters

v (int) – node id.

Returns

eps_neighbors – list of node’s eps-neighbor

Return type

list

fit(g)[source]

Fitting model

Parameters

g (dgl.DGLGraph) – graph dataset.

hasLabel(cliques, vertex)[source]

judge whether the node is labeled

Parameters
  • cliques (dict) – cluster dict.

  • vertex (torch.tensor) – node id.

Returns

whether the node is labeled.

Return type

bool

predict(g)[source]

predict and return anomaly score of each node

Parameters

g (dgl.DGLGraph) – graph dataset.

Returns

score – anomaly score of each node.

Return type

numpy.ndarray

similarity(v, u)[source]

compute the similarity of two nodes’ neighbors

Parameters
  • v (int) – first node id.

  • u (int) – second node id.

Returns

sim – similarity of two nodes’ neighbors.

Return type

float

training: bool