Skip to content

Commit

Permalink
[.] Changes before release.
Browse files Browse the repository at this point in the history
  • Loading branch information
annoviko committed Dec 23, 2019
1 parent 3457a24 commit 594a933
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
6 changes: 6 additions & 0 deletions ccore/include/pyclustering/container/cftree.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once


class cfnode {

};
2 changes: 2 additions & 0 deletions ccore/src/ccore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<ClCompile Include="container\adjacency_list.cpp" />
<ClCompile Include="container\adjacency_matrix.cpp" />
<ClCompile Include="container\adjacency_weight_list.cpp" />
<ClCompile Include="container\cftree.cpp" />
<ClCompile Include="container\kdnode.cpp" />
<ClCompile Include="container\kdtree.cpp" />
<ClCompile Include="differential\differ_factor.cpp" />
Expand Down Expand Up @@ -172,6 +173,7 @@
<ClInclude Include="..\include\pyclustering\container\adjacency_list.hpp" />
<ClInclude Include="..\include\pyclustering\container\adjacency_matrix.hpp" />
<ClInclude Include="..\include\pyclustering\container\adjacency_weight_list.hpp" />
<ClInclude Include="..\include\pyclustering\container\cftree.hpp" />
<ClInclude Include="..\include\pyclustering\container\dynamic_data.hpp" />
<ClInclude Include="..\include\pyclustering\container\ensemble_data.hpp" />
<ClInclude Include="..\include\pyclustering\container\kdnode.hpp" />
Expand Down
6 changes: 6 additions & 0 deletions ccore/src/ccore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@
<ClCompile Include="utils\stats.cpp">
<Filter>Source Files\utils</Filter>
</ClCompile>
<ClCompile Include="container\cftree.cpp">
<Filter>Source Files\container</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\pyclustering\cluster\agglomerative.hpp">
Expand Down Expand Up @@ -633,5 +636,8 @@
<ClInclude Include="..\include\pyclustering\definitions.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\pyclustering\container\cftree.hpp">
<Filter>Header Files\container</Filter>
</ClInclude>
</ItemGroup>
</Project>
Empty file added ccore/src/container/cftree.cpp
Empty file.
27 changes: 11 additions & 16 deletions pyclustering/container/cftree.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,12 @@ class cfnode:
"""

def __init__(self, feature, parent, payload):
def __init__(self, feature, parent):
"""!
@brief Constructor of abstract CF node.
@param[in] feature (cfentry): Clustering feature of the created node.
@param[in] parent (cfnode): Parent of the created node.
@param[in] payload (*): Data that is stored by the node.
"""

Expand All @@ -380,9 +379,6 @@ def __init__(self, feature, parent, payload):

## Type node (leaf or non-leaf).
self.type = cfnode_type.CFNODE_DUMMY

## Payload of node where user data can be stored.
self.payload = payload


def __repr__(self):
Expand Down Expand Up @@ -431,7 +427,7 @@ def successors(self):
return self.__successors


def __init__(self, feature, parent, successors, payload):
def __init__(self, feature, parent, successors):
"""!
@brief Create CF Non-leaf node.
Expand All @@ -442,7 +438,7 @@ def __init__(self, feature, parent, successors, payload):
"""

super().__init__(feature, parent, payload)
super().__init__(feature, parent)

## Node type in CF tree that is CFNODE_NONLEAF for non leaf node.
self.type = cfnode_type.CFNODE_NONLEAF
Expand Down Expand Up @@ -568,18 +564,17 @@ def entries(self):
return self.__entries


def __init__(self, feature, parent, entries, payload):
def __init__(self, feature, parent, entries):
"""!
@brief Create CF Leaf node.
@param[in] feature (cfentry): Clustering feature of the created node.
@param[in] parent (non_leaf_node): Parent of the created node.
@param[in] entries (list): List of entries of the node.
@param[in] payload (*): Data that is stored by the node.
"""

super().__init__(feature, parent, payload)
super().__init__(feature, parent)

## Node type in CF tree that is CFNODE_LEAF for leaf node.
self.type = cfnode_type.CFNODE_LEAF
Expand Down Expand Up @@ -1008,7 +1003,7 @@ def __insert_for_noneleaf_node(self, entry, search_node):

# Check if it's aleady root then new root should be created (height is increased in this case).
if search_node is self.__root:
self.__root = non_leaf_node(search_node.feature, None, [search_node], None)
self.__root = non_leaf_node(search_node.feature, None, [search_node])
search_node.parent = self.__root

# Update statistics
Expand Down Expand Up @@ -1070,7 +1065,7 @@ def __split_procedure(self, split_node):
"""
if split_node is self.__root:
self.__root = non_leaf_node(split_node.feature, None, [ split_node ], None)
self.__root = non_leaf_node(split_node.feature, None, [ split_node ])
split_node.parent = self.__root

# Update statistics
Expand Down Expand Up @@ -1106,8 +1101,8 @@ def __split_nonleaf_node(self, node):
[farthest_node1, farthest_node2] = node.get_farthest_successors(self.__type_measurement)

# create new non-leaf nodes
new_node1 = non_leaf_node(farthest_node1.feature, node.parent, [farthest_node1], None)
new_node2 = non_leaf_node(farthest_node2.feature, node.parent, [farthest_node2], None)
new_node1 = non_leaf_node(farthest_node1.feature, node.parent, [farthest_node1])
new_node2 = non_leaf_node(farthest_node2.feature, node.parent, [farthest_node2])

farthest_node1.parent = new_node1
farthest_node2.parent = new_node2
Expand Down Expand Up @@ -1142,8 +1137,8 @@ def __split_leaf_node(self, node):
[farthest_entity1, farthest_entity2] = node.get_farthest_entries(self.__type_measurement)

# create new nodes
new_node1 = leaf_node(farthest_entity1, node.parent, [farthest_entity1], None)
new_node2 = leaf_node(farthest_entity2, node.parent, [farthest_entity2], None)
new_node1 = leaf_node(farthest_entity1, node.parent, [farthest_entity1])
new_node2 = leaf_node(farthest_entity2, node.parent, [farthest_entity2])

# re-insert other entries
for entity in node.entries:
Expand Down

0 comments on commit 594a933

Please sign in to comment.