|
ArKanjo 0.5.1
A tool for find code duplicated functions in codebases
|
Represents a similarity graph between functions (paths). More...
#include <similarity_table.hpp>
Public Types | |
| enum class | Cache_Compatibility { Success , Fail } |
Public Member Functions | |
| Similarity_Table (double _similarity_threshold) | |
| Constructs with custom similarity threshold. More... | |
| Similarity_Table () | |
| Constructs with default similarity threshold. More... | |
| Cache_Compatibility | load () |
| void | update_similarity (double new_similarity_threshold) |
| Updates similarity threshold. More... | |
| double | get_similarity (const Path &path1, const Path &path2) |
| Gets similarity between two paths. More... | |
| double | get_threshold_similarity () const |
| Gets the similarity threshold. More... | |
| const Path & | get_path (PathId id) const |
| bool | is_similar (const Path &path1, const Path &path2) |
| Checks if two paths are similar. More... | |
| void | normalize_pair (PathId &id1, PathId &id2) const |
| const std::vector< Path > & | get_path_list () const |
| Gets list of all known paths. More... | |
| int | get_number_lines_in_pair (const Path &path1, const Path &path2) |
| std::vector< Path > | get_similar_path_to_the_reference (const Path &reference) |
| Gets paths similar to reference path. More... | |
| std::vector< SimilarPair > | get_all_similar_pairs () |
| Gets all similar path pairs with scores, sorted. More... | |
| bool | compare_paths (const SimilarPair &a, const SimilarPair &b) const |
| void | sort_pairs_by_line_number (std::vector< SimilarPair > &similar_pairs) const |
| Sorts path pairs by line count. More... | |
| void | sort_pairs_by_similarity (std::vector< SimilarPair > &similar_pairs) const |
| Sorts path pairs by similarity. More... | |
| std::vector< Cluster > | get_clusters () |
| Generate clusters of similar functions using DFS on the similarity graph. More... | |
| std::vector< ClusterInfo > | get_clusters_info (bool sorted) |
| Returns detailed information about all clusters found in the similarity table. More... | |
Represents a similarity graph between functions (paths).
Each node corresponds to a function (identified by a Path). Stores pairs of similar functions with their similarity scores.
Internally:
paths stores all known functions.path_id maps a Path to its unique node ID.similarity_graph is an adjacency list representation: node -> [(neighbor_id, similarity), ...]similarity_table stores pairwise similarity for fast lookup.Graph interpretation:
Definition at line 104 of file similarity_table.hpp.
|
strong |
| Enumerator | |
|---|---|
| Success | |
| Fail | |
Definition at line 107 of file similarity_table.hpp.
|
explicit |
Constructs with custom similarity threshold.
| _similarity_threshold | Initial threshold value |
Definition at line 67 of file similarity_table.cpp.
|
explicit |
Constructs with default similarity threshold.
Definition at line 70 of file similarity_table.cpp.
| bool Similarity_Table::compare_paths | ( | const SimilarPair & | a, |
| const SimilarPair & | b | ||
| ) | const |
Definition at line 150 of file similarity_table.cpp.
| std::vector< SimilarPair > Similarity_Table::get_all_similar_pairs | ( | ) |
Gets all similar path pairs with scores, sorted.
Definition at line 128 of file similarity_table.cpp.
| std::vector< Cluster > Similarity_Table::get_clusters | ( | ) |
Generate clusters of similar functions using DFS on the similarity graph.
Only edges with similarity >= threshold are considered.
Definition at line 191 of file similarity_table.cpp.
| std::vector< ClusterInfo > Similarity_Table::get_clusters_info | ( | bool | sorted | ) |
Returns detailed information about all clusters found in the similarity table.
Definition at line 228 of file similarity_table.cpp.
Definition at line 184 of file similarity_table.cpp.
Definition at line 96 of file similarity_table.cpp.
| const std::vector< Path > & Similarity_Table::get_path_list | ( | ) | const |
Gets list of all known paths.
Definition at line 113 of file similarity_table.cpp.
Gets paths similar to reference path.
| reference | Path to compare against |
Definition at line 117 of file similarity_table.cpp.
Gets similarity between two paths.
| path1 | First path to compare |
| path2 | Second path to compare |
Definition at line 81 of file similarity_table.cpp.
| double Similarity_Table::get_threshold_similarity | ( | ) | const |
Gets the similarity threshold.
Definition at line 104 of file similarity_table.cpp.
Checks if two paths are similar.
| path1 | First path to compare |
| path2 | Second path to compare |
Definition at line 108 of file similarity_table.cpp.
| Similarity_Table::Cache_Compatibility Similarity_Table::load | ( | ) |
Definition at line 73 of file similarity_table.cpp.
Definition at line 8 of file similarity_table.cpp.
| void Similarity_Table::sort_pairs_by_line_number | ( | std::vector< SimilarPair > & | similar_pairs | ) | const |
Sorts path pairs by line count.
| similar_path_pairs | Pairs to sort |
Definition at line 172 of file similarity_table.cpp.
| void Similarity_Table::sort_pairs_by_similarity | ( | std::vector< SimilarPair > & | similar_pairs | ) | const |
Sorts path pairs by similarity.
| similar_path_pairs | Pairs to sort |
Definition at line 160 of file similarity_table.cpp.
| void Similarity_Table::update_similarity | ( | double | new_similarity_threshold | ) |
Updates similarity threshold.
| new_similarity_threshold | New threshold value |
Definition at line 77 of file similarity_table.cpp.