Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对pygraphviz不兼容 #58

Open
Minkelxy opened this issue Nov 27, 2024 · 3 comments
Open

对pygraphviz不兼容 #58

Minkelxy opened this issue Nov 27, 2024 · 3 comments

Comments

@Minkelxy
Copy link

似乎不符合标准的dot写法,dot修正了这些错误,但很多其他的软件对他支持不好,比如转义符,比如标签的字符应该有"".
我不熟悉DOT,不知道这个问题属于谁.

@Enter-tainer
Copy link
Owner

具体是什么错误呢 能给个能跑的例子吗,dot能跑,pygraphviz不能跑的

@Minkelxy
Copy link
Author

int main() {
  int n = read(), m = read();
  for (int i = 1; i <= n; i++) f[i][0] = read();
  pre();
  for (int j = 1; j <= logn; j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++)
      f[i][j] = max(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]);  // ST表具体实现
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    int s = Logn[y - x + 1];
    printf("%d\n", max(f[x][s], f[y - (1 << s) + 1][s]));
  }
  return 0;
}

我觉得两个地方要改
str.replace('\"', "\\\"")
换成

fn escape_dot_label(label: &str) -> String {
    label.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n")
}

然后是这里,少了边的"的转义符

                crate::graph::EdgeType::Branch(t) => res.push_str(
                    format!(
                        "D{}:{} -> D{}:n [xlabel=\"{}\"];\n",
                        i.source().index(),
                        if *t { "s" } else { "e" },
                        i.target().index(),
                        if *t { "Y" } else { "N" }
                    )
                    .as_str(),
                ),

@Enter-tainer
Copy link
Owner

你把对应的python代码也放上来吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants