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

Graphs #202

Open
Tracked by #116
simonsan opened this issue Jan 14, 2021 · 1 comment
Open
Tracked by #116

Graphs #202

simonsan opened this issue Jan 14, 2021 · 1 comment
Labels
A-pattern Area: Content about Patterns C-addition Category: Adding new content, something that didn't exist in the repository before C-needs discussion Area: Something that is not clear to everyone if it fixes something/adds valuable content E-help wanted Call for participation: Help is requested to fix this issue

Comments

@simonsan
Copy link
Collaborator

simonsan commented Jan 14, 2021

I think Graph data structure, on its own, is too wide topic to cover in a couple of pages. As a rule, complexity of algorithms on graphs directly depends their representation. What kind of representation we will choose depends on our use case. Factors to take into account:

  • type of graphs: complete graph, trees, directed, undirected, etc.
  • compute intensive: speed/complexity of algorithms is important, for example depending on representation DFS algorithm may work in O(n^2) or O(n + m).
  • scarce memory (embedded systems for example)
  • what kind of algorithm we implement: parallel, distributed...
  • Is graph dynamic?: we constantly add/remove vertices/edges...
  • amortised cost: for example amortised costs are given in documentations for some data structures.

Let me give a simple example. Say, I know my graph changes (new edges or vertex) once a day, but the graph is almost complete and in my algorithms I traverse neighbours of a single vertex not too often. I'd probably use adjacency matrix.

Or another example. If we know that our graph has too few edges and we do extensive DFS then matrix is a bad choice since it would have O(n^2) complexity, while using adj list we could reduce it to linear time O(n) if say m is linear in n.

Originally posted by @fade2black in #68 (comment)

@simonsan simonsan added C-addition Category: Adding new content, something that didn't exist in the repository before E-help wanted Call for participation: Help is requested to fix this issue C-needs discussion Area: Something that is not clear to everyone if it fixes something/adds valuable content labels Jan 14, 2021
@simonsan
Copy link
Collaborator Author

Closed #68 to focus on discussing the topic here, may be reopened later to use it as a basis for a general Graphs intro.md, not sure.

@simonsan simonsan added the A-pattern Area: Content about Patterns label Jan 21, 2021
@simonsan simonsan changed the title Graph data structures Graphs Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pattern Area: Content about Patterns C-addition Category: Adding new content, something that didn't exist in the repository before C-needs discussion Area: Something that is not clear to everyone if it fixes something/adds valuable content E-help wanted Call for participation: Help is requested to fix this issue
Projects
None yet
Development

No branches or pull requests

1 participant