Search Results for

    Show / Hide Table of Contents

    Class graph::CostEdge

    Edge subclass with an associated cost.

    This attaches a Cost (default type: double) to each edge in a graph. This is used, for instance, to represent the coefficients in the graph representation of an Ising cost function:

    Inheritance
    graph::Edge
    graph::CostEdge
    Inherited Members
    nodes_count
    clear_node_ids
    Edge
    Edge
    remove_node_id
    num_nodes
    add_node_id
    sort_node_ids
    node_ids
    ~Component
    Component
    param

    Constructors

    CostEdge()

    Declaration
    graph::CostEdge<Cost>::CostEdge()

    CostEdge()

    Declaration
    graph::CostEdge<Cost>::CostEdge(Cost c)

    CostEdge()

    Declaration
    graph::CostEdge<Cost>::CostEdge(Cost c, const std::vector<int>&node_ids)

    Methods

    cost()

    Accessor for the cost.

    Declaration
    Cost graph::CostEdge<Cost>::cost() const

    set_cost()

    Setter for the cost.

    Declaration
    void graph::CostEdge<Cost>::set_cost(Cost cost)

    configure()

    Serialize as a regular edge with an entry "c" for the cost.

    Declaration
    void graph::CostEdge<Cost>::configure(const utils::Json&json) override

    render()

    render the object in structured form

    Return a structured representation of the object. This is intended for output purposes. For instance, the solution your solver finds should have a render method which allows it to be returned as part of the result. Example:

    {c++}
     MySolution : public Component {
      public:
       // Represent the internal bool vector as +-1 output.
       utils::Structure render() const override {
         utils::Structure rendered;
         for (bool item : solution_) rendered.push_back(item ? 1 : -1);
         return rendered;
       }
    
      private:
       std::vector<bool> solution_;
     }
    
     MySolution solution;
     std::cout << solution.render().to_string() << std::endl;
    

    utils::Structure

    Declaration
    utils::Structure graph::CostEdge<Cost>::render() const override

    get_status()

    get_status shows a simplified state representation

    Like render, this produces a structured representation of the object's state. However, it is intended to be simpler in nature with the purpose of rendering the object during stream-output and logging. By default, it will fall back to the full render, but overloading this allows distinguising how the object looks during LOG vs full output.

    Declaration
    utils::Structure graph::CostEdge<Cost>::get_status() const override

    get_class_name()

    get_class_name shows an identifier of the (derived) class name

    Its primary use is for type identification during stream output and logging, where a component is rendered as <ClassName: status>. Example:

    {c++}
     MyClass : public Component {}
    
     // This will render as '<MyClass>'
     MyClass my_object;
     std::cout << my_object << std::endl;
    
    Note

    You do not need to overload this method unless you want to change the output of the default implementation.

    Declaration
    std::string graph::CostEdge<Cost>::get_class_name() const override

    rescale()

    Declaration
    void graph::CostEdge<Cost>::rescale(double scale_factor) override

    memory_estimate()

    Declaration
    static size_t graph::CostEdge<Cost>::memory_estimate(size_t num_nodes)
    In This Article
    Back to top Generated with Doxygen and DocFX