Transcript

TUGAS JARINGAN KOMPUTERALGORITMA DIJKSTRA DAN BELLMAN FORD

NAMANIM

ANDRE FEBRIAN OTNIELDBC 113 094

BAGUSTY VIRGONYDBC 113 060

FARHANIDBC 113 124

DESTIO R.DBC 113 114

JURUSAN TEKNIK INFORMATIKAFAKULTAS TEKNIKUNIVERSITAS PALANGKA RAYA2015

Algoritma Mencari Jalur Terpendek dengan Dijkstra dan Bellman FordSource Code Algoritma Bellman Ford dengan 100 node (tujuan node 1 ke 9) :W = [.31 .40 .61 .12 .35 .45 .50 .78 .56 .28 .49 ]; DG = sparse([6 1 2 7 100 8 4 5 9 6 1],[2 6 3 4 1 7 100 8 4 9 5],W) h = view(biograph(DG,[],'ShowWeights','on')) [dist,path,pred] = graphshortestpath(DG,1,9) set(h.Nodes(path),'Color',[1 0.4 0.4])edges = getedgesbynodeid(h,get(h.Nodes(path),'ID'));set(edges,'LineColor',[1 0 0])set(edges,'LineWidth',1.5) UG = tril(DG + DG') h = view(biograph(UG,[],'ShowArrows','off','ShowWeights','on')) [dist,path,pred] = graphshortestpath(UG,1,9,'directed',false) set(h.Nodes(path),'Color',[1 0.4 0.4]) fowEdges = getedgesbynodeid(h,get(h.Nodes(path),'ID')); revEdges = getedgesbynodeid(h,get(h.Nodes(fliplr(path)),'ID')); edges = [fowEdges;revEdges]; set(edges,'LineColor',[1 0 0]) set(edges,'LineWidth',1.5)

Outputnya :

Source Code Algoritma Dijkstra :noOfNodes = 100; rand('state', 0); figure(1); clf; hold on; L = 2000; R = 300; netXloc = rand(1,noOfNodes)*L; netYloc = rand(1,noOfNodes)*L; for i = 1:noOfNodes plot(netXloc(i), netYloc(i), '.'); text(netXloc(i), netYloc(i), num2str(i)); for j = 1:noOfNodes distance = sqrt((netXloc(i) - netXloc(j))^2 + (netYloc(i) - netYloc(j))^2); if distance


Top Related