summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Cluster.lua
blob: d7baed45daa5775e4fd384c2ef43183101fd58c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
-- Copyright 2011 by Jannis Pohlmann
-- Copyright 2012 by Till Tantau
--
-- This file may be distributed an/or modified
--
-- 1. under the LaTeX Project Public License and/or
-- 2. under the GNU Public License
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information

-- @release $Header$



--- The Cluster class defines a model of a cluster inside a graph.
--
--

local Cluster = {}
Cluster.__index = Cluster


-- Namespace



--- TODO Jannis: Add documentation for this class.
--
function Cluster.new(name)
  local cluster = {
    name = name,
    nodes = {},
    contains_node = {},
  }
  setmetatable(cluster, Cluster)
  return cluster
end



function Cluster:getName()
  return self.name
end



function Cluster:addNode(node)
  if not self:findNode(node) then
    self.contains_node[node] = true
    self.nodes[#self.nodes + 1] = node
  end
end



function Cluster:findNode(node)
  return self.contains_node[node]
end




-- Done

return Cluster