Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Documentation of type parameters #121

Open
matthew-dean opened this issue Dec 30, 2024 · 1 comment
Open

[Feature request] Documentation of type parameters #121

matthew-dean opened this issue Dec 30, 2024 · 1 comment

Comments

@matthew-dean
Copy link

matthew-dean commented Dec 30, 2024

Is your feature request related to a problem? Please describe.
In the docs, for all of the graphs, the types are undocumented, at least in the initial constructor. For example:
Screenshot 2024-12-30 at 8 53 19 AM

I presume V has something to do with a vertex (or a value??), and E has something to do with an edge, but... in terms of type-safety, where am I defining what my keys and values are? If you look at this, it says that the key is of type VertexKey, and value is of type V (which then makes me thing V in the original type is value?)... but these are types I define where exactly? In other words, if I want keys to be strings, and I want vertex types to be limited to a particular set, and edge values limited in the same way, for type hints and auto-complete, how would I do this in the types on the constructor?

Describe the solution you'd like
Documentation of TypeScript types for constructors.

Describe alternatives you've considered
I guess the alternative is tracing through the code to see how types are applied / utilized?

@zrwusa
Copy link
Owner

zrwusa commented Dec 31, 2024

In the Graph data structure, V refers to the value of a Vertex, which is used only when you need to store data on certain Vertices. The key of a Vertex is defined as type VertexKey = string | number;, meaning the key does not need to be explicitly specified and defaults to supporting string or number. Similarly, E represents the value of an Edge, while the key of an Edge is automatically managed and does not require specification.

In summary, for all Graph data structures, we only focus on the value types of Vertices and Edges

We apologize for not having example code for the Graph data structure at the moment, but we will be adding it soon. In the meantime, you can refer to some test case code:

DirectedGraph: https://github.com/zrwusa/data-structure-typed/blob/main/test/unit/data-structures/graph/directed-graph.test.ts
UndirectedGraph: https://github.com/zrwusa/data-structure-typed/blob/main/test/unit/data-structures/graph/undirected-graph.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants