|
Arkanjo 0.2
A tool for find code duplicated functions in codebases
|
Represents a similarity graph between functions (paths). More...
#include <similarity_table.hpp>
Public Member Functions | |
| Similarity_Table (double _similarity_threshold) | |
| Constructs with custom similarity threshold. | |
| Similarity_Table () | |
| Constructs with default similarity threshold. | |
| void | load () |
| void | update_similarity (double new_similarity_threshold) |
| Updates similarity threshold. | |
| double | get_similarity (const Path &path1, const Path &path2) |
| Gets similarity between two paths. | |
| bool | is_similar (const Path &path1, const Path &path2) |
| Checks if two paths are similar. | |
| const std::vector< Path > & | get_path_list () const |
| Gets list of all known paths. | |
| 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. | |
| std::vector< std::tuple< double, Path, Path > > | get_all_path_pairs_and_similarity_sorted_by_similarity () |
| Gets all similar path pairs with scores, sorted. | |
| std::vector< std::pair< Path, Path > > | get_all_similar_path_pairs_sorted_by_similarity () |
| Gets all similar path pairs, sorted by similarity. | |
| std::vector< std::pair< Path, Path > > | get_all_similar_path_pairs_sorted_by_line_number () |
| Gets all similar path pairs, sorted by line count. | |
| std::vector< Cluster > | get_clusters () |
| Generate clusters of similar functions using DFS on the similarity graph. | |
| std::vector< ClusterInfo > | get_clusters_info (bool sorted) |
| Returns detailed information about all clusters found in the similarity table. | |
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 99 of file similarity_table.hpp.
|
explicit |
Constructs with custom similarity threshold.
| _similarity_threshold | Initial threshold value |
Definition at line 50 of file similarity_table.cpp.
|
explicit |
Constructs with default similarity threshold.
Definition at line 53 of file similarity_table.cpp.
| std::vector< std::tuple< double, Path, Path > > Similarity_Table::get_all_path_pairs_and_similarity_sorted_by_similarity | ( | ) |
Gets all similar path pairs with scores, sorted.
Definition at line 105 of file similarity_table.cpp.
| std::vector< std::pair< Path, Path > > Similarity_Table::get_all_similar_path_pairs_sorted_by_line_number | ( | ) |
Gets all similar path pairs, sorted by line count.
Definition at line 146 of file similarity_table.cpp.
| std::vector< std::pair< Path, Path > > Similarity_Table::get_all_similar_path_pairs_sorted_by_similarity | ( | ) |
Gets all similar path pairs, sorted by similarity.
Definition at line 118 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 168 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 205 of file similarity_table.cpp.
Definition at line 160 of file similarity_table.cpp.
| const std::vector< Path > & Similarity_Table::get_path_list | ( | ) | const |
Gets list of all known paths.
Definition at line 90 of file similarity_table.cpp.
Gets paths similar to reference path.
| reference | Path to compare against |
Definition at line 94 of file similarity_table.cpp.
Gets similarity between two paths.
| path1 | First path to compare |
| path2 | Second path to compare |
Definition at line 64 of file similarity_table.cpp.
Checks if two paths are similar.
| path1 | First path to compare |
| path2 | Second path to compare |
Definition at line 85 of file similarity_table.cpp.
| void Similarity_Table::load | ( | ) |
Definition at line 56 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 60 of file similarity_table.cpp.