c# - basic graph data structure -


i trying write simple text-based game in unity player must navigate bed 'let's say, 'a'' exit, 'g' moving across 'nodes' directly attached. here's example of information trying elegantly capture:

a directly connected b, c, , d b directly connected , c c directly connected , b d directly connected , e e directly connected f , g f directly connected nothing (let's say, game over?) g directly connected e

so need able following: 1) store bank of nodes 2) store connections between nodes may one-way 3) track current position 4) (icing on cake) alter these connections things happen in-game

any implementation can create off top of head not scale to, let's say, 1000 nodes. how should tackle problem?

there variety of graph data structures may take at. suggest have @ informative discussions efficient graph data structure in thread:

https://softwareengineering.stackexchange.com/questions/148313/what-is-the-most-space-efficient-way-to-implement-a-graph-data-structure

one of efficient graph data structures may fit gaming purpose using adjacency matrix https://en.wikipedia.org/wiki/adjacency_matrix because may find moving character or object between 2 cells happen quite gaming. therefore, adjacency matrix helps find sibling cells of particular cell quite fast. however, approach requires memory store possible adjacencies between 2 sibling cells in graph.

however, if graph directed graph connections between 2 nodes one-way. may want @ adjacency list https://en.wikipedia.org/wiki/adjacency_list store list of adjacency nodes in every cell. takes less time sibling of particular cell.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -