{"id":26368777,"url":"https://github.com/bindreams/graph","last_synced_at":"2025-03-16T22:49:00.681Z","repository":{"id":167685059,"uuid":"261857228","full_name":"bindreams/graph","owner":"bindreams","description":"A collection of C++ classes for representing graphs.","archived":false,"fork":false,"pushed_at":"2025-03-07T15:17:47.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-07T16:25:37.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bindreams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-05-06T19:19:50.000Z","updated_at":"2025-03-07T15:17:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"e443ac79-1656-4171-aaa3-97689cfb3823","html_url":"https://github.com/bindreams/graph","commit_stats":null,"previous_names":["andreasxp/graph","bindreams/graph"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bindreams","download_url":"https://codeload.github.com/bindreams/graph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243945479,"owners_count":20372894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-16T22:49:00.138Z","updated_at":"2025-03-16T22:49:00.668Z","avatar_url":"https://github.com/bindreams.png","language":"C++","readme":"# `graph`\nA collection of C++ classes for representing graphs.\n\n# Installation\nGraph can be installed as a single-header library with no additional dependencies. It can be compiled using a favorite tool of your choice from `zh/graph.hpp`. Optionally it can also be used as a single CMake package or via `conan`.\n\nCMake offers the target `zh::graph` for linking with other libraries. Options graph_BUILD_TESTS and graph_BUILD_EXAMPLES (default off) can be turned on to build tests and examples for this library.\n\nConan package manager can be used to locally install this library with options `tests` and `examples` corresponding to the CMake switches.\n\n# Usage\nThe main class of this library is `zh::graph`:\n```C++\ntemplate \u003cclass T, class E\u003e\nclass graph;\n```\nWhere T and E are types of values to be stored in nodes and edges of the graph.\n\nGraph is a container - iterating over it will allow you to iteratre over it's node values:\n```C++\nzh::graph\u003cint\u003e g;\ng.emplace(1);\ng.emplace(2);\ng.emplace(3);\ng.emplace(4);\n\nfor (auto\u0026 i : g) {\n    std::cout \u003c\u003c i; // prints 1234\n}\n```\n`zh::graph` also allows you to iterate over it's nodes and edges directly:\n```C++\nfor (zh::node\u0026 i : g.nodes()) {\n}\n\nfor (zh::edge i : g.edges()) {\n}\n```\nNote that `edge` is not a reference - the graph does not store edges as objects and creates them on demand. `zh::edge` only holds information about the nodes, the direction, and the value.\n\n# Reference\n## zh::graph\nPublic functions:\n```C++\niterator       begin() noexcept;\nconst_iterator begin() const noexcept;\nconst_iterator cbegin() const noexcept;\n```\nIterator access to node values of the graph. Returns `iterator` or `const_iterator` to the first value.  \nNote: although values preserve insertion order, this behavior should not be relied upon and may be changed in future releases of `graph`.\n```C++\niterator       end() noexcept;\nconst_iterator end() const noexcept;\nconst_iterator cend() const noexcept;\n```\nIterator access to node values of the graph. Returns `iterator` or `const_iterator` to the past-the-end value.  \nNote: although values preserve insertion order, this behavior should not be relied upon and may be changed in future releases of `graph`.\n```C++\nnodes_view       nodes() noexcept;\nconst_nodes_view nodes() const noexcept;\n```\nProvides a view into the nodes of the graph. `nodes_view` is similar to `string_view` in that it provides a reference to values, and should not outlive the graph.\n```C++\nedges_view       edges() noexcept;\nconst_edges_view edges() const noexcept;\n```\nProvides a view into the nodes of the graph. `edges_view` is similar to `string_view` in that it provides a reference to values, and should not outlive the graph. Note that edges are not stored in the graph - `edges_view` generates them on demand.\n```C++\ntemplate \u003cclass... Args\u003e\nstatic void connect(node\u003cT, E\u003e\u0026 nd1, node\u003cT, E\u003e\u0026 nd2, Args\u0026\u0026... args);\ntemplate \u003cclass... Args\u003e\nstatic void connect(iterator it1, iterator it2, Args\u0026\u0026... args);\ntemplate \u003cclass... Args\u003e\nstatic void connect(node_iterator it1, node_iterator it2, Args\u0026\u0026... args);\n```\nConnects two nodes with an edge. The edge value is constructed from `args`. This function can connect two nodes, two iterators, or two node_iterators.\n```C++\nstatic void disconnect(node\u003cT, E\u003e\u0026 nd1, node\u003cT, E\u003e\u0026 nd2);\nstatic void disconnect(iterator it1, iterator it2);\nstatic void disconnect(node_iterator it1, node_iterator it2);\n```\nConnects two nodes with an edge. The edge value is destroyed. This function can disconnect two nodes, two iterators, or two node_iterators.\n```C++\nT\u0026       front();\nconst T\u0026 front() const;\n```\nAccess the value of the first node in the graph.  \nNote: although values preserve insertion order, this behavior should not be relied upon and may be changed in future releases of `graph`.\n```C++\nT\u0026       back();\nconst T\u0026 back() const;\n```\nAccess the value of the last node in the graph.  \nNote: although values preserve insertion order, this behavior should not be relied upon and may be changed in future releases of `graph`.\n```C++\nnode_iterator insert(const T\u0026 val);\nnode_iterator insert(T\u0026\u0026 val);\ntemplate \u003cclass InputIt\u003e\nvoid insert(InputIt first, InputIt last);\nvoid insert(std::initializer_list\u003cvalue_type\u003e ilist);\n```\nInserts values into the graph as new nodes.\n```C++\ntemplate \u003cclass... Args\u003e\nnode_iterator emplace(Args\u0026\u0026... args);\n```\nEmplaces a new node containing the `T` value constructed from `args`.\n```C++\niterator erase(iterator it);\nnode_iterator erase(node_iterator it);\nvoid erase(edge\u003cT, E\u003e e);\n```\nErases items from graph. Can erase a node via an iterator or node_iterator, or can erase an edge.\n```C++\nvoid clear() noexcept;\n```\nRemoves everything from the graph.\n```C++\nvoid reserve(size_type new_size);\n```\n```C++\nbool empty() const noexcept;\n```\n```C++\nstd::size_t size() const noexcept;\n```\n```C++\nstd::size_t capacity() const noexcept;\n```\n```C++\nstd::size_t count_edges() const noexcept;\n```\n```C++\ndouble ratio() const noexcept;\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbindreams%2Fgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbindreams%2Fgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbindreams%2Fgraph/lists"}