42 operator int()
const {
return value; }
60template<
typename Key,
typename Weight>
79 double w_density = 0.3;
113 static constexpr const double DEFAULT_SIMILARITY = 100.00;
114 static constexpr const double EPS_ERROR_MARGIN = 1e-6;
115 static constexpr const double MAXIMUM_SIMILARITY = 100.00;
116 static constexpr const double MINIMUM_SIMILARITY = 0.00;
118 double similarity_threshold;
119 std::vector<Path> paths;
120 std::map<Path, PathId> path_id;
126 std::map<std::pair<PathId, PathId>,
double> similarity_table;
142 void read_comparation(std::ifstream& table_file);
148 void read_file_table(std::ifstream& table_file);
160 bool is_above_threshold(
double similarity)
const;
Represents a logical path to a function in the codebase.
Represents a similarity graph between functions (paths).
void update_similarity(double new_similarity_threshold)
Updates similarity threshold.
std::vector< SimilarPair > get_all_similar_pairs()
Gets all similar path pairs with scores, sorted.
bool compare_paths(const SimilarPair &a, const SimilarPair &b) const
std::vector< ClusterInfo > get_clusters_info(bool sorted)
Returns detailed information about all clusters found in the similarity table.
int get_number_lines_in_pair(const Path &path1, const Path &path2)
const Path & get_path(PathId id) const
void sort_pairs_by_line_number(std::vector< SimilarPair > &similar_pairs) const
Sorts path pairs by line count.
Similarity_Table()
Constructs with default similarity threshold.
void sort_pairs_by_similarity(std::vector< SimilarPair > &similar_pairs) const
Sorts path pairs by similarity.
double get_similarity(const Path &path1, const Path &path2)
Gets similarity between two paths.
std::vector< Cluster > get_clusters()
Generate clusters of similar functions using DFS on the similarity graph.
void normalize_pair(PathId &id1, PathId &id2) const
const std::vector< Path > & get_path_list() const
Gets list of all known paths.
Cache_Compatibility load()
bool is_similar(const Path &path1, const Path &path2)
Checks if two paths are similar.
std::vector< Path > get_similar_path_to_the_reference(const Path &reference)
Gets paths similar to reference path.
double get_threshold_similarity() const
Gets the similarity threshold.
Configuration management interface.
Logical path abstraction for source code elements.
std::vector< std::vector< std::pair< Key, Weight > > > AdjacencyList
{ 1: [{ key, weight }, { key, weight }] 2: [{ key, weight }] 3: [] ... }
std::vector< Path > paths
Represents a cluster of similar functions in the similarity graph.
std::vector< int > members
List of node indices (Path IDs) in the cluster.
bool operator==(const PathId &other) const
bool operator!=(const PathId &other) const
bool operator<(const PathId &other) const