亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? vc+map.txt

?? vc+mapx編寫的最優(yōu)路徑算法
?? TXT
字號:
最短路徑算法實現(xiàn)!


#ifndef _topo_h__
#define _topo_h__
//////////////////////////////////////////////////////////////////////////
#define MAXWEIGHT 1000000000
#define DIFFVAL(v1, v2) (((v1) > (v2))? (v1)-(v2) : (v2)-(v1))

#pragma warning(disable:4786)
#include <vector>
using namespace std;


struct topo_node
{
union {
struct {
long x;
long y;
};

long nod[2];
};

topo_node(){}

topo_node(long lx, long ly)
{
x = lx;
y = ly;
}
};

struct topo_arc
{
union {
struct {
long id;// arc id links explict attrlist. aid identifies direction of an arc
long wt;// weight of arc
long na;// from node point
long nb;// to node point
};

long arc[4];
};

topo_arc(){}

topo_arc(long arcid, long weight, long from, long to)
{
id = arcid;
wt = weight;
na = from;
nb = to;
}
};

// A topo_path consistes of multiple topo_arc(s)
class topo_path
{
private:
vector<long> ipath;

public:
topo_path(){}

~topo_path(){
ipath.clear();
}

inline long& operator [](int i)
{
return ipath;
}

inline void pushback(long val)
{
ipath.push_back(val);
}

inline static void link(topo_path& pa, topo_path& pb, topo_path& res)
{
int sa = pa.size();
int sb = pb.size();
int size = sa+sb;
res.ipath.resize(size);

for (int i=0; i<sa; i++)
res.ipath = pa.ipath;

int j=0;
for (i=sa; i<size; i++)
res.ipath = pb.ipath[j++];
}

inline int size(){
return ipath.size();
}
};


class topo_network
{
typedef vector<topo_arc> arc_list;
typedef vector<topo_node> node_list;

// Data
unsigned short diff;// Tolerance units of network
arc_list arcs; // A vector of topo_arc(s)
node_list nodes; // A vector of topo_node(s)

// Adjacence matrix
long* arcmat;// Adjacence matrix of arc ids
long* wtmat;// Adjacence matrix of weights of arcs

// Floyd & Dijkstra
topo_path* pathmat;

// Dijkstra
long* sel;
long* dist;

public:

topo_network(unsigned short difference=1)
{
diff = difference;
arcmat = NULL;
wtmat = NULL;
pathmat = NULL;

sel = NULL;
dist = NULL;
}

~topo_network(){
delete[] arcmat;
delete[] wtmat;
delete[] pathmat;
delete[] sel;
}

void initDiff(unsigned short difference) {
diff = difference;
}

// Add a edge to arcs, if have a reverse edge simultaneously, add it as well.
void addArc(long arcid, long weight, 
long xfrom, long yfrom, 
long xto, long yto,
bool bHaveRev = false)
{
// traverse nodes firstly
topo_arc arc(arcid, weight, 0, 0);
long nod;
long size = nodes.size();

bool bAddFrom = false;
bool bAddTo = false;
for (long i=0; i<size; i++) {
if ( !bAddFrom && DIFFVAL(nodes.x, xfrom) < diff && DIFFVAL(nodes.y, yfrom) < diff) {
arc.na = i;
bAddFrom = true;
}

if ( !bAddTo && DIFFVAL(nodes.x, xto) < diff && DIFFVAL(nodes.y, yto) < diff) {
arc.nb = i;
bAddTo = true;
}
}

if (!bAddFrom) {
topo_node node(xfrom, yfrom);
nodes.push_back(node);
arc.na = nodes.size()-1;
}

if (!bAddTo) {
topo_node node(xto, yto);
nodes.push_back(node);
arc.nb = nodes.size()-1;
}

arcs.push_back(arc);
if (bHaveRev) {
nod = arc.nb;
arc.nb = arc.na;
arc.na = nod;
arc.id = -arc.id;

arcs.push_back(arc);
}
}

long sizeArcs(){
return arcs.size();
}

long sizeNodes(){
return nodes.size();
}

// Create adjacency matrix for storing topo_network.
bool createAdjMatrix() {
long size = nodes.size();
long length = size*size;
try{
if (arcmat)
delete[] arcmat;
if (wtmat)
delete[] wtmat;
if (pathmat)
delete[] pathmat;

arcmat = new long [length];
wtmat = new long [length];
pathmat = new topo_path [length];
}
catch(...){
arcmat = NULL;
wtmat = NULL;
pathmat = NULL;
return false;
}

if (!arcmat || !wtmat || !pathmat)
return false;

// Initialize with sensely value.
for (long row=0; row<size; row++) {
for (long col=0; col<size; col++) {
long q = row*size+col;
arcmat[q] = -1;
if (row == col) 
wtmat[q] = 0;
else
wtmat[q] = MAXWEIGHT;
}
}

// Filling weight in it
long count = arcs.size();
for (long k=0; k<count; k++) {
long i = arcs[k].na;
long j = arcs[k].nb;
long q = i*size+j;
arcmat[q] = k;
wtmat[q] = arcs[k].wt;
pathmat[q].pushback(k);
}

return true;
}

void Floyd()
{
long v = 0;
long size = nodes.size();

for (int k=0; k<size; k++) {
for (int i=0; i<size; i++) {
for (int j=0; j<size; j++) {
long ij = i*size+j;
long ik = i*size+k;
long kj = k*size+j;

v = wtmat[i*size+k] + wtmat[k*size+j];

if (v < wtmat[ij]) {
wtmat[ij] = v;
topo_path::link(pathmat[ik], pathmat[kj], pathmat[ij]);
}
}
}
}
}

// Get path from isrc to idst using Dijkstra Algorithm.
void Dijkstra (long isrc)
{
long size = nodes.size();

if (sel)
delete[] sel;
sel = new long [size];

// Dist is a reference to weight matrix, so we NEED NOT allocate and free it.
dist = wtmat + isrc*size;

// Initialize sel
for (int i=0; i<size; i++)
sel = 0;
sel[isrc] = 1;// Select isrc to selection

// Select the min dist j to selection.
for (long k=0; k<size-1; k++) {

long wt = MAXWEIGHT;
long j = isrc;

for (i=0; i<size; i++) {
if (sel!=1 && dist < wt) {// (v!=1) is faster than (v==0)
j = i;
wt = dist;
}
}
sel[j] = 1;// Add j to sel which dist[j] is min.
//if (j==isrc)
//break;

// Modify dist[]
for (i=0; i<size; i++) {
long w = dist[j] + wtmat[j*size+i]; // weight from j to i plus from isrc to j.

if (sel != 1 && w < dist ) {
dist = w;
// Desc: path[isrc, i] = path[isrc, j] + path[j,i];
topo_path::link(pathmat[isrc*size+j], pathmat[j*size+i], pathmat[isrc*size+i]);
}
}
}
}

topo_path& getPath(long isrc, long idst, long* length=NULL)
{
int q = isrc*sizeNodes() + idst;

if (length)
*length = wtmat[q];

return pathmat[q];
}

// i must be a valid index of arcs
topo_arc getArc(long i) {
topo_arc a = arcs;
return a;
}

// Get index of node in nodes
long getNodeIndex(long lx, long ly) {
long size = nodes.size();

for (long i=0; i<size; i++) {
if ( DIFFVAL(nodes.x, lx) < diff && DIFFVAL(nodes.y, ly) < diff)
return i;
}

return -1;// Invalid index
}
};

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99re热视频精品| 1区2区3区精品视频| 亚洲一区二区三区四区中文字幕| 国产真实乱偷精品视频免| 69堂成人精品免费视频| 久久久久久久久蜜桃| 免费久久99精品国产| 制服.丝袜.亚洲.另类.中文| 亚洲第一福利一区| 欧洲一区在线观看| 亚洲欧洲中文日韩久久av乱码| 成人免费视频一区| 欧美国产精品一区二区| 成人精品视频网站| 中文字幕在线一区免费| aaa亚洲精品| 亚洲欧洲精品一区二区三区| 国产精品99久久久久久有的能看 | 韩国av一区二区三区四区| 日韩一级免费一区| 国产一区二区三区蝌蚪| 中文字幕亚洲不卡| 欧美精品久久99久久在免费线| 久久精品国产精品亚洲综合| 国产日产欧美一区| 欧美性videosxxxxx| 免费成人美女在线观看.| 精品国产精品一区二区夜夜嗨| 春色校园综合激情亚洲| 午夜欧美视频在线观看| 日本一区二区免费在线| 欧美日韩亚洲综合在线 | 91色九色蝌蚪| 天堂一区二区在线免费观看| 久久精品在线免费观看| 欧美影视一区二区三区| 国产一区视频导航| 亚洲成人中文在线| 国产日产欧产精品推荐色 | 国产成人午夜99999| 亚洲一区二区在线播放相泽| 久久久亚洲欧洲日产国码αv| 色哟哟国产精品免费观看| 日本aⅴ亚洲精品中文乱码| 亚洲欧洲另类国产综合| 精品国产亚洲在线| 欧美乱熟臀69xxxxxx| 成人综合婷婷国产精品久久蜜臀| 午夜国产精品影院在线观看| 136国产福利精品导航| 精品国产91洋老外米糕| 欧美久久一区二区| 色婷婷狠狠综合| 国产成人午夜精品影院观看视频 | 成人动漫在线一区| 麻豆精品视频在线观看免费 | 一区二区三区国产| 久久日韩精品一区二区五区| 欧美老女人在线| 欧美午夜视频网站| 99久久99久久综合| 成人免费观看男女羞羞视频| 麻豆国产精品视频| 图片区日韩欧美亚洲| 亚洲精品视频免费看| 中文字幕国产精品一区二区| 久久久久久久久久久久久女国产乱 | 天天操天天色综合| 一区二区三区电影在线播| 亚洲欧美自拍偷拍色图| 中文字幕第一区综合| 精品国产凹凸成av人网站| 欧美一区二区国产| 欧美精品久久天天躁| 欧美日韩精品一区视频| 欧美日韩久久久久久| 欧美亚洲动漫精品| 欧美艳星brazzers| 91福利在线观看| 一本久久精品一区二区| 91麻豆蜜桃一区二区三区| 成人午夜视频在线| 成人福利在线看| 99精品视频在线观看免费| 99久久久久免费精品国产| 99精品偷自拍| 欧美唯美清纯偷拍| 欧美日韩高清一区二区三区| 欧美高清hd18日本| 日韩一级大片在线| 2023国产精品自拍| 久久久精品2019中文字幕之3| 久久蜜桃一区二区| 国产精品美女久久福利网站| 国产精品白丝在线| 亚洲视频每日更新| 亚洲精品免费在线播放| 亚洲国产一区视频| 久久精品二区亚洲w码| 国产九色精品成人porny| 成人不卡免费av| 99精品久久久久久| 欧美日韩一级片在线观看| 日韩欧美一二区| 中文字幕免费在线观看视频一区| 自拍偷拍欧美激情| 日韩一区欧美二区| 国产一区二区在线视频| 99精品欧美一区二区蜜桃免费| 在线看日韩精品电影| 日韩一区二区三免费高清| 久久久不卡影院| 亚洲永久精品国产| 精一区二区三区| 色综合天天综合| 6080亚洲精品一区二区| 国产性天天综合网| 亚洲中国最大av网站| 乱一区二区av| 色综合一区二区三区| 91精品国产福利在线观看| 国产精品乱码一区二区三区软件 | 国产乱子轮精品视频| 色av一区二区| 精品免费日韩av| 亚洲激情成人在线| 国产伦精品一区二区三区免费| 欧美在线免费视屏| 欧美国产乱子伦| 免费在线观看精品| 色吊一区二区三区| 国产欧美精品国产国产专区| 亚洲国产日韩在线一区模特| 国产高清在线精品| 欧美妇女性影城| 亚洲激情综合网| 国产高清亚洲一区| 欧美一区二区三区视频免费 | 国产一本一道久久香蕉| 欧美性淫爽ww久久久久无| 中文字幕欧美区| 国产一区免费电影| 69久久夜色精品国产69蝌蚪网| 亚洲欧美自拍偷拍色图| 国产麻豆精品视频| 日韩色在线观看| 亚洲午夜激情av| 91视频在线观看| 欧美国产一区在线| 捆绑紧缚一区二区三区视频| 欧美亚洲日本一区| 亚洲免费观看高清完整| 国产一区二区久久| 精品日本一线二线三线不卡| 午夜成人免费电影| 欧美综合欧美视频| 亚洲男同1069视频| 99国产一区二区三精品乱码| 久久精品人人做| 韩日欧美一区二区三区| 日韩欧美专区在线| 亚洲成人精品影院| 欧美三级三级三级爽爽爽| 有坂深雪av一区二区精品| 99精品视频中文字幕| 成人免费在线播放视频| 99久久亚洲一区二区三区青草| 欧美激情一区在线| 成人少妇影院yyyy| 亚洲欧洲另类国产综合| 99国产精品久久久久| 亚洲男人的天堂在线观看| 日本黄色一区二区| 一区二区免费在线| 欧美男男青年gay1069videost | 国产精品黄色在线观看| 国产91精品露脸国语对白| 国产精品―色哟哟| 成人黄色av电影| 亚洲精品免费在线观看| 欧美日韩一区二区三区四区 | 精品久久国产97色综合| 黄色精品一二区| 欧美激情一区在线观看| 99热在这里有精品免费| 一片黄亚洲嫩模| 欧美一区二区三区电影| 久久成人免费网| 中文字幕精品一区二区三区精品| 99久久777色| 午夜视频久久久久久| 日韩欧美亚洲国产另类| 国产精品一线二线三线| 中文字幕日韩一区| 欧美午夜精品一区二区蜜桃| 日韩黄色片在线观看| 久久久www成人免费无遮挡大片| av激情成人网| 日韩福利视频导航| 中文字幕欧美日本乱码一线二线|