Hacker News new | ask | show | jobs
by _zachs 2531 days ago
I disagree with the author’s points that you can’t represent a graph with a single interface. Write an interface with the methods you need, i.e., `findNeighbors()`, `getAllFriends()`, `retrieveDogPhotos()`, and implement it for the specific underlying data structure/implementation of Graph you choose later. A graph is a graph, the interface doesn’t care if you’re using an adjacency matrix or a node. I don’t see how writing a mathematical function would be more robust and helpful in designing and implementing those features.
1 comments

Can you represent Facebook's graph of friends as an interface?

Do you think they also do a lot of graph theory about it?

`getFriends(userId)`, how's that? :D