翻转单条边时图的平均测地距离的变化

发布于 2024-11-08 07:42:00 字数 1353 浏览 3 评论 0原文

如果我添加或删除一条比计算前后距离然后减去的速度更快的边,有没有什么方法可以找出图的平均测地距离会改变多少?

我正在对一个系统进行 Metropolis Monte Carlo 模拟,该系统的状态由无向图表示。系统的能量取决于该图的平均测地距离。

在每个蒙特卡罗步骤中,我必须提出对图的修改,然后计算由于该修改而引起的能量变化。我只是选择一个随机边缘并翻转它(如果不存在则添加边缘,如果存在则删除边缘)。我现在所做的是一种蛮力:

Graph = initialize;
L = avgGeodesicLength(Graph)
E0 = energy(L)
for(i = 0; i < mcsteps; i++) {
   newGraph = copy Graph;
   flip a random edge of newGraph;
   L = avgGeodesicLength(newGraph);
   E1 = energy(L);
   dE = E1 - E0
   if (metropolis criteria(dE) is true) {
      Graph = newGraph;
      E0 = E1;
   } 
   else {
      throw the copy away and keep the current state;
   }
}

我宁愿这样做:

Graph = initialize;
L = avgGeodesicLength(Graph);
E0 = energy(L);
for(i = 0; i < mcsteps; i++) {
   edge = random edge of Graph;
   dL = difference in AvgGeodesicLength if I flip edge;
   dE = differenceInEnergy(dL);
   if (metropolis criteria(dE) is true) {
      flip edge; 
      E0 += dE;
   }
   else { do nothing;}
}

如果计算能量差比计算能量本身快得多。如果有一种方法可以计算平均测地线长度的差异,并且给定的边以更快的方式(大 O 方向)翻转,则这是可能的。

有办法做到这一点吗?我知道很难预测单个边缘的变化会影响哪些路径,但是......也许我很幸运! :D

编辑:我不在乎我必须为您想到的任何算法使用任何表示形式。如果可以节省我的时间,我愿意这样做。

我的图通常很小(顶点数量通常少于一百个,边数在少数和完全连接之间变化)。问题是我必须重复这个循环很多很多步骤才能达到平衡,并且它们为很多很多不同条件中的每一个计算许多可观测值...:(

编辑2:我不需要单独的测地线路径或其长度,只有平均测地线长度。

Is there any way to find how much would the average geodesic distance of a graph will change if I add or remove a single edge that's faster then calculating the distance before and after and then subtracting?

I'm doing a Metropolis Monte Carlo simulation of a system whose state is represented by an undirected graph. The energy of the system depends on the average geodesic distance of this graph.

At each monte carlo step I must propose a modification of the graph and then calculate the change in energy due to that modification. I'm just selecting a random edge and flipping it (add the edge if it's not present, remove the edge if it's present). What I do now is kind of brute force:

Graph = initialize;
L = avgGeodesicLength(Graph)
E0 = energy(L)
for(i = 0; i < mcsteps; i++) {
   newGraph = copy Graph;
   flip a random edge of newGraph;
   L = avgGeodesicLength(newGraph);
   E1 = energy(L);
   dE = E1 - E0
   if (metropolis criteria(dE) is true) {
      Graph = newGraph;
      E0 = E1;
   } 
   else {
      throw the copy away and keep the current state;
   }
}

I'd rather do this:

Graph = initialize;
L = avgGeodesicLength(Graph);
E0 = energy(L);
for(i = 0; i < mcsteps; i++) {
   edge = random edge of Graph;
   dL = difference in AvgGeodesicLength if I flip edge;
   dE = differenceInEnergy(dL);
   if (metropolis criteria(dE) is true) {
      flip edge; 
      E0 += dE;
   }
   else { do nothing;}
}

if calculating the difference in energy was substantially faster than calculating the energy itself. This is possible if there's a way to calculate the difference in the average geodesic length if a given edge is flipped in a much faster way (big-O-wise).

Is there a way to do this? I know it's difficult to predict what paths will be affected by a change in a single edge, but... maybe I'm lucky! :D

EDIT: I don't care whatever representation I must use for any algorithms you have in mind. If it saves my time, I'm willing to do it.

My graphs are usually kind of small (number of vertices usually less than a hundred, number of edges varies between a handful and fully connected). The problem is that I must repeat this loop for many, many steps to achieve equilibrium and them calculate many observables for each of many, many different conditions... :(

EDIT 2: I don't need the individual geodesic paths or their lengths, only the average geodesic lengths.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文