[#llvm-xray-Graph] = xref:llvm.adoc[llvm]::xref:llvm/xray.adoc[xray]::Graph :relfileprefix: ../../ :mrdocs: A Graph object represents a Directed Graph and is used in XRay to compute and store function call graphs and associated statistical information. == Synopsis Declared in `<llvm/XRay/Graph.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename VertexAttribute, typename EdgeAttribute, typename VI = int32_t> class Graph; ---- == Description The graph takes in four template parameters, these are: * VertexAttribute, this is a structure which is stored for each vertex. Must be DefaultConstructible, CopyConstructible, CopyAssignable and Destructible. * EdgeAttribute, this is a structure which is stored for each edge Must be DefaultConstructible, CopyConstructible, CopyAssignable and Destructible. * EdgeAttribute, this is a structure which is stored for each variable * VI, this is a type over which DenseMapInfo is defined and is the type used look up strings, available as VertexIdentifier. * If the built in DenseMapInfo is not defined, provide a specialization class type here. Graph is CopyConstructible, CopyAssignable, MoveConstructible and MoveAssignable but is not EqualityComparible or LessThanComparible. Usage Example Graph with weighted edges and vertices: Graph<int, int, int> G; G[1]= 0; G[2]= 2; G[{1,2}]= 1; G[{2,1}]= ‐1; for(const auto &v : G.vertices()){ // Do something with the vertices in the graph; } for(const auto &e : G.edges()){ // Do something with the edges in the graph; } Usage Example with StrRef keys. Graph<int, double, StrRef> StrG; char va[]= "Vertex A"; char vaa[]= "Vertex A"; char vb[]= "Vertex B"; // Vertices are referenced by String Refs. G[va]= 0; G[vb]= 1; G[{va, vb}]= 1.0; cout() << G[vaa]<< " " << G[{vaa, vb}]; //prints "0 1.0". == Types [cols="1,4"] |=== | Name| Description | xref:llvm/xray/Graph/EdgeView.adoc[`EdgeView`] | A class for ranging over all the edges in the graph. | xref:llvm/xray/Graph/InOutEdgeView.adoc[`InOutEdgeView`] | A class for ranging over the incoming edges incident to a vertex. | xref:llvm/xray/Graph/VertexView.adoc[`VertexView`] | A class for ranging over the vertices in the graph. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:llvm/xray/Graph/ConstEdgeIterator.adoc[`ConstEdgeIterator`] | A const iterator for iterating through the entire edge set of the graph. | xref:llvm/xray/Graph/ConstInEdgeIterator.adoc[`ConstInEdgeIterator`] | A const iterator type for iterating through the set of edges entering a vertex. | xref:llvm/xray/Graph/ConstOutEdgeIterator.adoc[`ConstOutEdgeIterator`] | A const iterator type for iterating through the set of edges entering a vertex. | xref:llvm/xray/Graph/ConstVertexIterator.adoc[`ConstVertexIterator`] | A const iterator type for iterating through the whole vertex set of the graph. | xref:llvm/xray/Graph/EdgeIdentifier.adoc[`EdgeIdentifier`] | Identifies an edge by its source and destination vertex identifiers. | xref:llvm/xray/Graph/EdgeIterator.adoc[`EdgeIterator`] | An iterator for iterating through the entire edge set of the graph. | xref:llvm/xray/Graph/EdgeValueType.adoc[`EdgeValueType`] | This type is the value_type of all iterators which range over edges, Determined by the Edges DenseMap. | xref:llvm/xray/Graph/InEdgeIterator.adoc[`InEdgeIterator`] | An iterator type for iterating through the set of edges leaving a vertex. | xref:llvm/xray/Graph/OutEdgeIterator.adoc[`OutEdgeIterator`] | An iterator type for iterating through the set of edges leaving a vertex. | xref:llvm/xray/Graph/VertexIdentifier.adoc[`VertexIdentifier`] | These objects are used to name edges and vertices in the graph. | xref:llvm/xray/Graph/VertexIterator.adoc[`VertexIterator`] | An iterator type for iterating through the whole vertex set of the graph. | xref:llvm/xray/Graph/VertexValueType.adoc[`VertexValueType`] | This type is the value_type of all iterators which range over vertices, Determined by the Vertices DenseMap | xref:llvm/xray/Graph/size_type.adoc[`size_type`] | Type used for sizes and counts in this graph. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:llvm/xray/Graph/at-0f.adoc[`at`] | `at` overloads | xref:llvm/xray/Graph/clear.adoc[`clear`] | Empty the Graph | xref:llvm/xray/Graph/count-08.adoc[`count`] | `count` overloads | xref:llvm/xray/Graph/edges-0f.adoc[`edges`] | `edges` overloads | xref:llvm/xray/Graph/inEdges-00.adoc[`inEdges`] | `inEdges` overloads | xref:llvm/xray/Graph/insert-08.adoc[`insert`] | `insert` overloads | xref:llvm/xray/Graph/operator_subs-0375.adoc[`operator[]`] | Subscript operators | xref:llvm/xray/Graph/outEdges-06.adoc[`outEdges`] | `outEdges` overloads | xref:llvm/xray/Graph/vertices-093.adoc[`vertices`] | `vertices` overloads |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#