class Graph

Declaration

template <typename VertexAttribute,
          typename EdgeAttribute,
          typename VI = int32_t>
class Graph { /* full declaration omitted */ };

Description

A Graph object represents a Directed Graph and is used in XRay to compute and store function call graphs and associated statistical information. 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".

Declared at: llvm/include/llvm/XRay/Graph.h:74

Templates

VertexAttribute
EdgeAttribute
VI = int32_t

Method Overview

  • public Expected<VertexAttribute &> at(const llvm::xray::Graph::VertexIdentifier & I)
  • public Expected<const VertexAttribute &> at(const llvm::xray::Graph::VertexIdentifier & I) const
  • public Expected<EdgeAttribute &> at(const llvm::xray::Graph::EdgeIdentifier & I)
  • public Expected<const EdgeAttribute &> at(const llvm::xray::Graph::EdgeIdentifier & I) const
  • public void clear()
  • public llvm::xray::Graph::size_type count(const llvm::xray::Graph::VertexIdentifier & I) const
  • public llvm::xray::Graph::size_type count(const llvm::xray::Graph::EdgeIdentifier & I) const
  • public EdgeView<false> edges()
  • public EdgeView<true> edges() const
  • public InOutEdgeView<false, false> inEdges(const llvm::xray::Graph::VertexIdentifier I)
  • public InOutEdgeView<true, false> inEdges(const llvm::xray::Graph::VertexIdentifier I) const
  • public std::pair<EdgeIterator, bool> insert(std::pair<EdgeIdentifier, EdgeAttribute> && Val)
  • public std::pair<EdgeIterator, bool> insert(const std::pair<EdgeIdentifier, EdgeAttribute> & Val)
  • public std::pair<VertexIterator, bool> insert(std::pair<VertexIdentifier, VertexAttribute> && Val)
  • public std::pair<VertexIterator, bool> insert(const std::pair<VertexIdentifier, VertexAttribute> & Val)
  • public InOutEdgeView<true, true> outEdges(const llvm::xray::Graph::VertexIdentifier I) const
  • public InOutEdgeView<false, true> outEdges(const llvm::xray::Graph::VertexIdentifier I)
  • public VertexView<true> vertices() const
  • public VertexView<false> vertices()

Methods

Expected<VertexAttribute&> at(
    const llvm::xray::Graph::VertexIdentifier& I)

Description

Looks up a vertex with Identifier I, or an error if it does not exist.

Declared at: llvm/include/llvm/XRay/Graph.h:398

Parameters

const llvm::xray::Graph::VertexIdentifier& I

Expected<const VertexAttribute&> at(
    const llvm::xray::Graph::VertexIdentifier& I)
    const

Declared at: llvm/include/llvm/XRay/Graph.h:407

Parameters

const llvm::xray::Graph::VertexIdentifier& I

Expected<EdgeAttribute&> at(
    const llvm::xray::Graph::EdgeIdentifier& I)

Description

Looks up an edge with Identifier I, or an error if it does not exist.

Declared at: llvm/include/llvm/XRay/Graph.h:417

Parameters

const llvm::xray::Graph::EdgeIdentifier& I

Expected<const EdgeAttribute&> at(
    const llvm::xray::Graph::EdgeIdentifier& I)
    const

Declared at: llvm/include/llvm/XRay/Graph.h:426

Parameters

const llvm::xray::Graph::EdgeIdentifier& I

void clear()

Description

Empty the Graph

Declared at: llvm/include/llvm/XRay/Graph.h:340

llvm::xray::Graph::size_type count(
    const llvm::xray::Graph::VertexIdentifier& I)
    const

Description

Looks for a vertex with identifier I, returns 1 if one exists, and 0 otherwise

Declared at: llvm/include/llvm/XRay/Graph.h:437

Parameters

const llvm::xray::Graph::VertexIdentifier& I

llvm::xray::Graph::size_type count(
    const llvm::xray::Graph::EdgeIdentifier& I)
    const

Description

Looks for an edge with Identifier I, returns 1 if one exists and 0 otherwise

Declared at: llvm/include/llvm/XRay/Graph.h:443

Parameters

const llvm::xray::Graph::EdgeIdentifier& I

EdgeView<false> edges()

Description

Returns a view object allowing iteration over the edges of the graph. also allows access to the size of the edge set.

Declared at: llvm/include/llvm/XRay/Graph.h:355

EdgeView<true> edges() const

Declared at: llvm/include/llvm/XRay/Graph.h:357

InOutEdgeView<false, false> inEdges(
    const llvm::xray::Graph::VertexIdentifier I)

Description

Returns a view object allowing iteration over the edges which point to a vertex I.

Declared at: llvm/include/llvm/XRay/Graph.h:371

Parameters

const llvm::xray::Graph::VertexIdentifier I

InOutEdgeView<true, false> inEdges(
    const llvm::xray::Graph::VertexIdentifier I)
    const

Declared at: llvm/include/llvm/XRay/Graph.h:375

Parameters

const llvm::xray::Graph::VertexIdentifier I

std::pair<EdgeIterator, bool> insert(
    std::pair<EdgeIdentifier, EdgeAttribute>&&
        Val)

Description

Inserts an edge into the graph with Identifier Val.first, and Attribute Val.second. If the key is already in the map, it returns false and doesn't update the value.

Declared at: llvm/include/llvm/XRay/Graph.h:478

Parameters

std::pair<EdgeIdentifier, EdgeAttribute>&& Val

std::pair<EdgeIterator, bool> insert(
    const std::pair<EdgeIdentifier,
                    EdgeAttribute>& Val)

Description

Inserts an edge into the graph with Identifier Val.first, and Attribute Val.second. If the key is already in the map, it returns false and doesn't update the value.

Declared at: llvm/include/llvm/XRay/Graph.h:461

Parameters

const std::pair<EdgeIdentifier, EdgeAttribute>& Val

std::pair<VertexIterator, bool> insert(
    std::pair<VertexIdentifier, VertexAttribute>&&
        Val)

Declared at: llvm/include/llvm/XRay/Graph.h:453

Parameters

std::pair<VertexIdentifier, VertexAttribute>&& Val

std::pair<VertexIterator, bool> insert(
    const std::pair<VertexIdentifier,
                    VertexAttribute>& Val)

Description

Inserts a vertex into the graph with Identifier Val.first, and Attribute Val.second.

Declared at: llvm/include/llvm/XRay/Graph.h:448

Parameters

const std::pair<VertexIdentifier, VertexAttribute>& Val

InOutEdgeView<true, true> outEdges(
    const llvm::xray::Graph::VertexIdentifier I)
    const

Declared at: llvm/include/llvm/XRay/Graph.h:365

Parameters

const llvm::xray::Graph::VertexIdentifier I

InOutEdgeView<false, true> outEdges(
    const llvm::xray::Graph::VertexIdentifier I)

Description

Returns a view object allowing iteration over the edges which start at a vertex I.

Declared at: llvm/include/llvm/XRay/Graph.h:361

Parameters

const llvm::xray::Graph::VertexIdentifier I

VertexView<true> vertices() const

Declared at: llvm/include/llvm/XRay/Graph.h:351

VertexView<false> vertices()

Description

Returns a view object allowing iteration over the vertices of the graph. also allows access to the size of the vertex set.

Declared at: llvm/include/llvm/XRay/Graph.h:349