The Library Algorithms API Wrappers Bayesian Nets Compression Containers Graph Tools Image Processing Linear Algebra Machine Learning Metaprogramming Miscellaneous Networking Optimization Parsing Help/Info Examples: C++ Assignment_Learning Base64_Encoder Bayesian_Network Bayesian_Network_From_Disk Bayesian_Network_GUI Bridge BSP Cmd_Line_Parser Compress_Stream Config_File_Reader Custom_Trainers Directory_Navigation Empirical_Kernel_Map Face_Detection FHOG_Feature_Extraction FHOG_Object_Detection Graph_Labeling GUI HTTP_Server Image IO Socket Streams IO Streams Server Kernel_Centroid Kernel_K-Means_Clustering Kernel_Ridge_Regression Kernel_RLS_Filtering Kernel_RLS_Regression KRR_Classification Learning_to_Track Linear_Manifold_Regularizer Logger Logger_Advanced Matrix Matrix_Expressions Member_Function_Pointer Model_Selection Multiclass_Classification Multithreaded_Object Neural_Network Non-Linear Least Squares Numerical_Integration Object_Detector Object_Detector_Advanced One_Class_Classifiers Online_SVM Optimization Parallel_For_Loops Pipe Pipe_2 Quantum_Computing Queue Rank_Features Relevance_Vector_Classification Relevance_Vector_Regression Running_Stats Sequence_Labeling Sequence_Segmentation Sockets Sockstreambuf Sparse_Vectors Std_C++_Allocator Structural_Support_Vector_Machines Support_Vector_Machine Support_Vector_Regression SURF SVM-Rank Threaded_Object Threads Thread_Function Thread_Pool Timer Train_Object_Detector Using_Custom_Kernels XML_Parser Examples: Python Face_Detector Linear_Assignment_Problems Sequence_Segmenter Structural_Support_Vector_Machines SVM-Rank Train_Object_Detector FAQ Home How to compile How to contribute Index Introduction License Python API Suggested Books Current Release Change Log Release Notes Version: 18.7 |
Last Modified: Nov 17, 2013
| # Graph Tools In dlib, there are two types of graph representations. On the one hand, there are graphs based on an object which encapsulates the whole graph, such as the graph and directed_graph objects. On the other hand, there are graphs which are represented as simple vectors of edges. In this case, we use vectors of sample_pair or ordered_sample_pair objects for undirected and directed graphs respectively. |
Graph Object Based Graphs copy_graph copy_graph_structure create_join_tree create_moral_graph edge find_connected_nodes graph_contains_directed_cycle graph_contains_length_one_cycle graph_contains_undirected_cycle graph_has_symmetric_edges graph_is_connected is_clique is_join_tree is_maximal_clique triangulate_graph_and_find_cliques Creating Edge List Based Graphs Distance Functions cosine_distance negative_dot_product_distance squared_euclidean_distance find_approximate_k_nearest_neighbors find_k_nearest_neighbors find_k_nearest_neighbors_lsh find_percent_shortest_edges_randomly ordered_sample_pair sample_pair Using Edge List Based Graphs contains_duplicate_pairs convert_unordered_to_ordered find_neighbor_ranges is_ordered_by_index max_index_plus_one order_by_descending_distance order_by_distance order_by_distance_and_index order_by_index remove_duplicate_edges remove_long_edges remove_percent_longest_edges remove_percent_shortest_edges remove_short_edges use_gaussian_weights use_weights_of_one |

[top]

# contains_duplicate_pairs

This function checks if a std::vector of sample_pair or ordered_sample_pair objects contains any edge more than once.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# convert_unordered_to_ordered

This function takes a graph, defined by a vector of sample_pair objects and converts it into the equivalent graph defined by a vector of ordered_sample_pair objects.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# copy_graph

This function takes a graph or directed_graph and makes a copy of it.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# copy_graph_structure

This function takes a graph or directed_graph and copies its structure to another graph or directed_graph object. The only restriction is that you can't copy the structure of a graph into a directed_graph. The three other possible combinations are allowed however.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# cosine_distance

This is a simple function object that computes cosine of the angle between two vectors.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# create_join_tree

This function takes a graph object and creates a join tree for that graph. Or in other words, this function finds a tree decomposition of the given graph.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# create_moral_graph

This function takes a directed_graph and returns the moralized version of the graph in the form of a graph object.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# edge

This function takes a graph or directed_graph object and a pair of indices. It returns a reference to the edge object between the two nodes with the given indices.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# find_approximate_k_nearest_neighbors

This function is a simple approximate form of find_k_nearest_neighbors. Instead of checking all possible edges it randomly samples a large number of them and then performs exact k-nearest-neighbors on that randomly selected subset.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# find_connected_nodes

This function takes a node from a graph or directed_graph object and a set of unsigned longs. It finds all the nodes in the given graph that are connected to the given node by an undirected path and returns them in the set (also note that the original query node is also returned in this set).
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# find_k_nearest_neighbors

This is a function which finds all the k nearest neighbors of a set of points and outputs the result as a vector of sample_pair objects. It takes O(n^2) time where n is the number of data samples. A faster approximate version is provided by find_approximate_k_nearest_neighbors and find_k_nearest_neighbors_lsh.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# find_k_nearest_neighbors_lsh

This function is a simple approximate form of find_k_nearest_neighbors. It uses locality sensitive hashing to speed up the nearest neighbor computation and is also capable of using a multi-core CPU.
`#include <dlib/graph_utils_threaded.h>`
Detailed Documentation
[top]

# find_neighbor_ranges

This function takes a graph, defined by a vector of ordered_sample_pair objects, and finds the ranges that contain the edges for each node in the graph. The output therefore lets you easily locate the neighbors of any node in the graph.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# find_percent_shortest_edges_randomly

This function is a simple approximate form of find_k_nearest_neighbors. Instead of checking all possible edges it randomly samples a large number of them and then returns the best ones.
`#include <dlib/graph_utils.h>`
Detailed Documentation
C++ Example Programs: linear_manifold_regularizer_ex.cpp
[top]

# graph_contains_directed_cycle

This function checks a directed_graph for directed cycles.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# graph_contains_length_one_cycle

This function takes a graph or directed_graph object and returns true if and only if the graph contains a node that has an edge that links back to itself.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# graph_contains_undirected_cycle

This function checks a directed_graph for undirected cycles.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# graph_has_symmetric_edges

This function checks if a directed_graph has a pair of nodes with just one edge between them. If so then it does not have symmetric edges.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# graph_is_connected

This function takes a graph or directed_graph object and determines if the graph is connected. That is, it returns true if and only if there is an undirected path between any two nodes in the given graph.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# is_clique

This function takes a graph and a set of node index values and checks if the specified set of nodes is a clique in the graph.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# is_join_tree

This function takes two graph objects and checks if the second of the two graphs is a valid join tree (aka tree decomposition) of the first graph.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# is_maximal_clique

This function takes a graph and a set of node index values and checks if the specified set of nodes is a maximal clique in the graph.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# is_ordered_by_index

This function checks if a vector of sample_pair or ordered_sample_pair objects is in sorted order according to their index values.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# max_index_plus_one

This function finds the number that is one greater than the largest index value in a std::vector of sample_pair or ordered_sample_pair objects. Therefore, it is useful for finding out how many nodes are in an edge list graph (assuming the graph contains all node indices from 0 to the largest index indicated by an edge).
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# negative_dot_product_distance

This is a simple function object that computes -dot(v1,v2) for two vectors v1 and v2.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# ordered_sample_pair

This object is intended to represent an edge in a directed graph which has data samples at its vertices. Therefore, it is the directed version of sample_pair.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# order_by_descending_distance

This function provides a total ordering of sample_pair or ordered_sample_pair objects that causes pairs with largest distance to be the first in a sorted list. This function can be used with std::sort().
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# order_by_distance

This function provides a total ordering of sample_pair or ordered_sample_pair objects that causes pairs with smallest distance to be the first in a sorted list. This function can be used with std::sort().
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# order_by_distance_and_index

This function provides a total ordering of sample_pair or ordered_sample_pair objects that causes pairs with smallest distance to be the first in a sorted list but also orders samples with equal distances according to order_by_index(). This function can be used with std::sort().
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# order_by_index

This function provides a total ordering of sample_pair or ordered_sample_pair objects that will cause pairs that represent the same edge to be adjacent when sorted. So for example, this function can be used with std::sort() to first sort a sequence of sample_pair objects and then find duplicate edges.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# remove_duplicate_edges

This is a simple function for removing duplicate edges (i.e. edges that compare equal according to ==) from a vector of sample_pair or ordered_sample_pair objects.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# remove_long_edges

This is a simple function for removing edges with a large distance value from a vector of sample_pair or ordered_sample_pair objects.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# remove_percent_longest_edges

This is a simple function for removing edges with a large distance value from a vector of sample_pair or ordered_sample_pair objects.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# remove_percent_shortest_edges

This is a simple function for removing edges with a small distance value from a vector of sample_pair or ordered_sample_pair objects.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# remove_short_edges

This is a simple function for removing edges with a small distance value from a vector of sample_pair or ordered_sample_pair objects.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# sample_pair

This object is intended to represent an edge in an undirected graph which has data samples at its vertices. Therefore, it is the undirected version of ordered_sample_pair.
`#include <dlib/graph_utils.h>`
Detailed Documentation
C++ Example Programs: linear_manifold_regularizer_ex.cpp
[top]

# squared_euclidean_distance

This is a simple function object that computes squared euclidean distance between two matrix objects.
`#include <dlib/graph_utils.h>`
Detailed Documentation
C++ Example Programs: linear_manifold_regularizer_ex.cpp
[top]

# triangulate_graph_and_find_cliques

This function takes a graph and turns it into a chordal graph. It also returns a set that contains all the cliques present in the chordal graph.
`#include <dlib/graph_utils.h>`
Detailed Documentation
[top]

# use_gaussian_weights

This is a simple function object that takes a single argument which should be an object similar to sample_pair.
`#include <dlib/graph_utils.h>`
Detailed Documentation
C++ Example Programs: linear_manifold_regularizer_ex.cpp
[top]

# use_weights_of_one

This is a simple function object that takes a single argument and always returns 1
`#include <dlib/graph_utils.h>`
Detailed Documentation