algorithm - Storing data for trees and graphs? -



algorithm - Storing data for trees and graphs? -

in tree or graph problems tried solve,the input entire tree or graph construction in node1->leafs or node1->adjacent nodes format.

is there list of commonly used structures save info in memory later helps intended algorithm.for example:

say have list of graph nodes like: 1 3 8 2 4.....# 1 connected 3 8 2 4...nodes 2 5 1 3... # 2 connected 5 1 3...nodes 3 1 2... #likewise . ... 8 ......

so if want utilize random contraction algorithm (in have contract edges contract 1 , 8..i utilize multi-linked list construction in each node on adjacency list points corresponding row i.e.8 in first line points 8th node.

now question,why chose construction store data?

contracting making 1 , 8 1 single entity,

so read 1's adjacency list starting 3 , go 3rds adjacency list alter 1 8 , next 8's row create 1 8 go 2's list alter 1 8....and append 1s list 8 , remove duplicates..yep,so 1 deleted graph after contracting 1 , 8

i want know or used structures storing trees , graphs,if associated algos algo name well?thank you

one mutual way store graphs utilize n-by-n matrix, n number of vertices in graph. if wanted store adjacency, if x matrix, x[i][j] = 1 if vertex j reachable vertex i, , 0 otherwise. store border costs or border capacities in manner. disadvantage of course of study amount of memory beingness used, o(n^2) instead of o(n+m) m number of edges, advantage o(1) lookup every possible vertex pair.

floyd's algorithm solving pairs shortest paths problem can naturally create utilize of such matrix, more complex sub-cubic algorithms solving various graph paths problems utilize faster matrix multiplication on ring.

algorithm data-structures graph tree

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -