java - graph representation with minimum cost (time and space) -
i have represent graph in java neither adjacency list nor adjacency matrix..
the basic idea if
deg[i]
is exit degree of vertex i, neigboors can store in
edges[i][j]
i <= j <= deg[i]
, given
edges[][]
must initialized values dont know how make differ adjacency matrix..
any suggestions?
in knowledge there 2 ways represent graph in language.
- either use adjacency matrix
- or use incidence matrix
you can make incidence matrix like
e1 e2 e3 e4
v1 1 2 1 1
v2 2 1 2 1
v3 1 1 1 2
v4 1 1 2 1
Comments
Post a Comment