回溯法解决地图填色问题

2023-11-10

目录

回溯法

最大度优先

最少可选颜色优先

向前探测

随机产生不同规模的图,分析算法效率与图规模的关系(四色)


回溯法

回溯法的基本思想是采用递归和深度优先搜索的方法,尝试在一组可能的解中搜索出符合要求的解,在搜索过程中,若发现当前所选的方案不能得到正解,就回溯到前面的某一步(即撤销上一次的选择),换一种可能性继续尝试,直到找到符合要求的解或者所有的可能性都已尝试完毕。

在地图填色中,回溯法从某一区域开始,如图4所示,尝试使用不同的颜色进行填充,然后递归地尝试填充相邻的区域,如果发现当前填充颜色与相邻区域的颜色冲突,则回溯到之前的状态重新选择一种颜色进行填充,如此往复直到所有的区域都被填充上颜色或者无解。

图4 回溯法地图填色示例

伪代码

C++代码 

#include<iostream>
#include<fstream>
#include<chrono>
#include<sstream>

using namespace std;
void fillColor(const int);
int map[450][450] = {0};
int color[450] = {0};
const int colorNumber = 4;
int vertexNumber = 0;
int edgeNumber = 0;
int solution = 0;
int done=0;
fstream file("C:\\Users\\Yezi\\Desktop\\C++\\MapColoring\\Map\\le9_4.txt");
string line, word;

int main() {
    if (!file.is_open()) {
        cout << "File error.\n";
        return 1;
    }
    getline(file, line);
    istringstream iss(line);
    iss >> word >> word >> vertexNumber >> edgeNumber;
    int head, tail;
    for (int i = 0; i < edgeNumber; i++) {
        getline(file, line);
        istringstream ISS(line);
        ISS >> word >> head >> tail;
        map[tail - 1][head - 1] = map[head - 1][tail - 1] = 1;
    }
    auto start = chrono::high_resolution_clock::now();
    fillColor(0);
    auto end = chrono::high_resolution_clock::now();
    auto consume = chrono::duration_cast<chrono::milliseconds>(end - start);
    cout << "There is " << solution << " solutions.\n" << "The time consumed is " << consume.count()
         << " ms.\n";
    return 0;
}

bool conflict(const int &vertex) {
    for (int i = 0; i < vertexNumber; i++) {
        if (map[vertex][i] && color[vertex] == color[i])
            return true;
    }
    return false;
}

void fillColor(const int vertex) {
    if(done==vertexNumber){
        solution++;
        for(int i=0;i<vertexNumber;i++)
            cout<<color[i]<<' ';
        cout<<endl;
        return;
    }
    for(int i=1;i<=colorNumber;i++){
        color[vertex]=i;
        if(!conflict(vertex)){
            done++;
            fillColor(vertex + 1);
            done--;
        }
        color[vertex]=0;
    }
}

运行结果

如图5所示,对于小规模地图,回溯法成功在323毫秒内找出480个解,并将每个解打印出来,验证了算法的正确性。

图5 回溯法小规模地图填色

对附件中给定的地图数据填涂;

首先还是用经典回溯法试跑一下,只找一个解的情况,如表1所示。

表1 经典回溯法大规模地图填色

由结果可以看出,当规模大时,回溯法的搜索空间会变得非常庞大,从而需要耗费大量的时间和内存资源来完成搜索过程,这将导致算法的运行时间呈指数级增长,短时间内无法求解。因此,我们需要对回溯法进行优化。

最大度优先

经典回溯法的问题在于解的空间太大,回溯次数太多,而优先选择邻边个数最多的顶点进行填色则会对剩下未填色的顶点产生更多的限制,从而减少回溯的次数,如图6所示,每次填色,我们都优先填度最大的区域。

图6 最大度优先地图填色示例

伪代码

C++代码 

#include<iostream>
#include<fstream>
#include<chrono>
#include<sstream>

using namespace std;
struct Vertex{
    int degree=0;
    int place;
}vertex[450];
void fillColor(const int);
int map[450][450] = {0};
int color[450] = {0};
const int colorNumber = 15;
int vertexNumber = 0;
int edgeNumber = 0;
int solution = 0;
int done=0;
fstream file("C:\\Users\\Yezi\\Desktop\\C++\\MapColoring\\Map\\le450_15b.txt");
string line, word;

int main() {
    if (!file.is_open()) {
        cout << "File error.\n";
        return 1;
    }
    getline(file, line);
    istringstream iss(line);
    iss >> word >> word >> vertexNumber >> edgeNumber;
    int head, tail;
    for (int i = 0; i < edgeNumber; i++) {
        getline(file, line);
        istringstream ISS(line);
        ISS >> word >> head >> tail;
        map[tail - 1][head - 1] = map[head - 1][tail - 1] = 1;
    }
    for(int i=0;i<vertexNumber;i++){
        vertex[i].place=i;
        for(int j=0;j<vertexNumber;j++){
            vertex[i].degree+=map[i][j];
        }
    }
    sort(vertex,vertex+vertexNumber,[](const Vertex&a,const Vertex&b){return a.degree>b.degree;});
    auto start = chrono::high_resolution_clock::now();
    fillColor(0);
    auto end = chrono::high_resolution_clock::now();
    auto consume = chrono::duration_cast<chrono::milliseconds>(end - start);
    cout << "We had found " << solution << " solutions.\n" << "The time consumed is " << consume.count()
         << " ms.\n";
    return 0;
}

bool conflict(const int &vertexIndex) {
    for (int i = 0; i < vertexNumber; i++) {
        if (map[vertexIndex][i] && color[vertexIndex] == color[i])
            return true;
    }
    return false;
}

void fillColor(const int vertexIndex) {
    if(done==vertexNumber){
        solution++;
        return;
    }
    for(int i=1;i<=colorNumber;i++){
        color[vertex[vertexIndex].place]=i;
        if(!conflict(vertex[vertexIndex].place)){
            done++;
            fillColor(vertexIndex + 1);
            if(solution>0)
                return;
            done--;
        }
        color[vertex[vertexIndex].place]=0;
    }
}

运行结果

先在小规模地图上验证算法的正确性,如图7所示,最大度优先可以在325毫秒内找出480个解。

图7 最大度优先小规模地图填色

然后尝试填涂三个大规模地图,只找一个解的情况,如表2所示。

表2 最大度优先大规模地图填色

由结果可知,我们的最大度优先优化策略略显成效,但是第一个和第二个地图还是无法在短时间内找到解,我们需要继续努力。

最少可选颜色优先

每次选择区域进行填色时优先选择剩余可用颜色最少的区域进行填色,这样可以减少剩余可用颜色最多的地区需要尝试不同颜色的次数,如图8所示,每填完一个区域就更新邻近区域的可选颜色,然后优先选择可选颜色最少的区域进行填色。

图8 最少可选颜色优先地图填色示例

伪代码

C++代码 

#include<iostream>
#include<fstream>
#include<chrono>
#include<sstream>
#include<vector>
using namespace std;
void fillColor(const int);
int map[450][450] = {0};
int color[450] = {0};
const int colorNumber = 25;
bool colorAccess[450][colorNumber+1];
int degree[450]={0};
int colorAccessNumber[450];
int vertexNumber = 0;
int edgeNumber = 0;
int solution = 0;
int done=0;
fstream file("C:\\Users\\Yezi\\Desktop\\C++\\MapColoring\\Map\\le450_25a.txt");
string line, word;

int main() {
    if (!file.is_open()) {
        cout << "File error.\n";
        return 1;
    }
    getline(file, line);
    istringstream iss(line);
    iss >> word >> word >> vertexNumber >> edgeNumber;
    int head, tail;
    for (int i = 0; i < edgeNumber; i++) {
        getline(file, line);
        istringstream ISS(line);
        ISS >> word >> head >> tail;
        map[tail - 1][head - 1] = map[head - 1][tail - 1] = 1;
    }
    for(int i=0;i<vertexNumber;i++){
        for(int j=1;j<=colorNumber;j++)
            colorAccess[i][j]= true;
        for(int j=0;j<vertexNumber;j++)
            degree[i]+=map[i][j];
    }
    auto start = chrono::high_resolution_clock::now();
    fillColor(0);
    auto end = chrono::high_resolution_clock::now();
    auto consume = chrono::duration_cast<chrono::milliseconds>(end - start);
    cout << "There is " << solution << " solutions.\n" << "The time consumed is " << consume.count()
         << " ms.\n";
    return 0;
}

bool conflict(const int &vertex) {
    for (int i = 0; i < vertexNumber; i++) {
        if (map[vertex][i] && color[vertex] == color[i])
            return true;
    }
    return false;
}
int MRV(const int vertex,vector<int>&MRVRecover){
    for(int i=0;i<vertexNumber;i++){
        if(map[vertex][i]){
            if(colorAccess[i][color[vertex]]){
                MRVRecover.push_back(i);
                colorAccess[i][color[vertex]]= false;
            }
        }
    }
    int next=0;
    int minColor=colorNumber;
    for(int i=0;i<vertexNumber;i++){
        colorAccessNumber[i]=0;
        for(int j=1;j<=colorNumber;j++){
            if(colorAccess[i][j])
                colorAccessNumber[i]++;
        }
        if(minColor>colorAccessNumber[i]&&color[i]==0){
            minColor=colorAccessNumber[i];
            next=i;
        }
    }
    return next;
}
void MRV_Recover(const int vertex,vector<int>&MRVRecover){
    for(auto&it:MRVRecover){
        colorAccess[it][color[vertex]]= true;
    }
}
void fillColor(const int vertex) {
    if(done==vertexNumber){
        solution++;
//        for(int i=0;i<vertexNumber;i++)
//            cout<<color[i]<<' ';
//        cout<<endl;
        return;
    }
    for(int i=1;i<=colorNumber;i++){
        color[vertex]=i;
        if(!conflict(vertex)){
            done++;
            vector<int>MRVRecover;
            int next= MRV(vertex,MRVRecover);
            fillColor(next);
            if(solution>0)
                return;
            MRV_Recover(vertex,MRVRecover);
            done--;
        }
        color[vertex]=0;
    }
}

运行结果

先在小规模地图上验证算法的正确性,如图9所示,可以在321毫秒内找出480个解。

图9 最少可选颜色小规模地图填色

然后尝试填涂三个大规模地图,结果如表3所示

表3 最少可选颜色优先大规模地图填色

由结果可知,最少可选颜色优先的优化策略使得第一个图也可以在2秒内找到解了,通过算法的优化,原本短时间内无解的问题可以迅速解决。

然后我们尝试将最大度优先和最少可选颜色优先结合去填涂三个大规模地图,结果如表4所示。

表4 最少可选颜色+最大度地图填色

由结果可知,将最少可选颜色优先和最大度优先相结合后,三个地图均可以迅速找到解,其中第一个地图需要600毫秒,而第二个地图在3秒内终于找到了一个解。

继续测试,对第一个地图找全部解,对第二个和第三个地图找10万个解,结果如表5所示,可知该优化策略可以迅速找解。

表5 最少可选颜色+最大度找多解

向前探测

每次选择区域进行填色的时候,先判断该填涂的颜色是否会导致邻近的区域无色可填,如果导致了邻近区域无色可填则直接换一种颜色填涂,如图10所示,每填一个区域就更新邻近区域的可用颜色,如果可用颜色为0则说明此处不能填这个颜色,进行剪枝。

图10 向前探测地图填色示例

伪代码

C++代码 

#include<iostream>
#include<fstream>
#include<chrono>
#include<sstream>
#include<vector>
using namespace std;
void fillColor(const int);
int map[450][450] = {0};
int color[450] = {0};
const int colorNumber = 5;
bool colorAccess[450][colorNumber+1];
int colorAccessNumber[450];
int vertexNumber = 0;
int edgeNumber = 0;
int solution = 0;
int done=0;
fstream file("C:\\Users\\Yezi\\Desktop\\C++\\MapColoring\\Map\\le450_5a.txt");
string line, word;

int main() {
    if (!file.is_open()) {
        cout << "File error.\n";
        return 1;
    }
    getline(file, line);
    istringstream iss(line);
    iss >> word >> word >> vertexNumber >> edgeNumber;
    int head, tail;
    for (int i = 0; i < edgeNumber; i++) {
        getline(file, line);
        istringstream ISS(line);
        ISS >> word >> head >> tail;
        map[tail - 1][head - 1] = map[head - 1][tail - 1] = 1;
    }
    for(int i=0;i<vertexNumber;i++){
        for(int j=1;j<=colorNumber;j++)
            colorAccess[i][j]= true;
    }
    auto start = chrono::high_resolution_clock::now();
    fillColor(0);
    auto end = chrono::high_resolution_clock::now();
    auto consume = chrono::duration_cast<chrono::milliseconds>(end - start);
    cout << "There is " << solution << " solutions.\n" << "The time consumed is " << consume.count()
         << " ms.\n";
    return 0;
}

bool conflict(const int &vertex) {
    for (int i = 0; i < vertexNumber; i++) {
        if (map[vertex][i] && color[vertex] == color[i])
            return true;
    }
    return false;
}

void FC_Recover(const int vertex,vector<int>&FCRecover){
    for(auto&it:FCRecover){
        colorAccess[it][color[vertex]]= true;
    }
}
bool FC(const int vertex,vector<int>&FCRecover){
    for(int i=0;i<vertexNumber;i++){
        if(map[vertex][i]){
            if(colorAccess[i][color[vertex]]){
                FCRecover.push_back(i);
                colorAccess[i][color[vertex]]= false;
            }
        }
    }
    for(int i=0;i<vertexNumber;i++){
        colorAccessNumber[i]=0;
        for(int j=1;j<=colorNumber;j++){
            if(colorAccess[i][j])
                colorAccessNumber[i]++;
        }
        if(colorAccessNumber[i]==0&&color[i]==0){
            FC_Recover(vertex,FCRecover);
            return false;
        }
    }
    return true;
}
void fillColor(const int vertex) {
    if(done==vertexNumber){
        solution++;
//        for(int i=0;i<vertexNumber;i++)
//            cout<<color[i]<<' ';
//        cout<<endl;
        return;
    }
    for(int i=1;i<=colorNumber;i++){
        color[vertex]=i;
        vector<int>FCRecover;
        if(!conflict(vertex)&&FC(vertex,FCRecover)){
            done++;
            fillColor(vertex+1);
            if(solution>0)
                return;
            done--;
            FC_Recover(vertex,FCRecover);
        }
        color[vertex]=0;
    }
}

运行结果

先在小规模地图上验证算法的正确性,如图11所示,可以在412毫秒内找出480个解。

图11 向前探测小规模地图填色

然后尝试填涂三个大规模地图,结果如表6所示。

表6 向前探测大规模地图填色

由结果可知,单纯的向前探测无法在短时间内找出三个地图的解,下面我们将向前探测和最大度优先结合起来,填涂三个大规模地图,结果如表7所示。

表7 向前探测+最大度地图填色

再加上最少可选颜色优先,填涂三个大地图,结果如表8所示。

表8 向前探测+最少可选颜色+最大度地图填色

对第一个地图找全部解,对第二个和第三个地图找10万个解,结果如表9所示。

表9 向前探测+最少可选颜色+最大度找多解

由此可知,与最大度优先和最少可选颜色优先相比,向前探测的优化效果不是特别明显。

随机产生不同规模的图,分析算法效率与图规模的关系(四色)

(1)固定边

固定图的边数为1000条边,然后随机生成顶点数为100到1000的平面图,测试多组数据取众数,结果如图12所示。

图12 固定边为1000不同顶点数的地图填色

具体数据如表10所示。

表10 固定边为1000不同顶点数的地图填色

由结果可知,边数固定的情况,顶点数越多,消耗的时间和资源也更多,解的搜索空间变大,搜索时间更长。

(2)固定点

固定图的顶点数为100,随机生成边数为100到1000的平面图,测试多组数据取众数,结果如图13所示。

图13 固定点为100不同边数的地图填色

具体数据如表10所示。

表10 固定点为100不同边数的地图填色

由结果分析,算法执行的时间先是随着边数的增加而增加,这是因为解的搜索空间增加了,而后当边数达到一定程度,边密度越大,图变得更加复杂,可选的颜色减少,算法剪枝的效率更高,所以搜索效率会更高。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

回溯法解决地图填色问题 的相关文章

  • 使用 gcc 在 Linux 上运行线程构建块 (Intel TBB)

    我正在尝试为线程构建块构建一些测试 不幸的是 我无法配置 tbb 库 链接器找不到库 tbb 我尝试在 bin 目录中运行脚本 但这没有帮助 我什至尝试将库文件移动到 usr local lib 但这又失败了 任何的意见都将会有帮助 确定您
  • 在模板类中声明模板友元类时出现编译器错误

    我一直在尝试实现我自己的链表类以用于教学目的 我在迭代器声明中指定了 List 类作为友元 但它似乎无法编译 这些是我使用过的 3 个类的接口 Node h define null Node
  • STL 迭代器:前缀增量更快? [复制]

    这个问题在这里已经有答案了 可能的重复 C 中的预增量比后增量快 正确吗 如果是 为什么呢 https stackoverflow com questions 2020184 preincrement faster than postinc
  • C# 异步等待澄清?

    我读了here http blog stephencleary com 2012 02 async and await html that 等待检查等待的看看它是否有already完全的 如果 可等待已经完成 那么该方法将继续 运行 同步
  • 通过引用传递 [C++]、[Qt]

    我写了这样的东西 class Storage public Storage QString key const int value const void add item QString int private QMap
  • C++11 删除重写方法

    Preface 这是一个关于最佳实践的问题 涉及 C 11 中引入的删除运算符的新含义 当应用于覆盖继承父类的虚拟方法的子类时 背景 根据标准 引用的第一个用例是明确禁止调用某些类型的函数 否则转换将是隐式的 例如最新版本第 8 4 3 节
  • 如何从本机 C(++) DLL 调用 .NET (C#) 代码?

    我有一个 C app exe 和一个 C my dll my dll NET 项目链接到本机 C DLL mynat dll 外部 C DLL 接口 并且从 C 调用 C DLL 可以正常工作 通过使用 DllImport mynat dl
  • 如何连接重叠的圆圈?

    我想在视觉上连接两个重叠的圆圈 以便 becomes 我已经有部分圆的方法 但现在我需要知道每个圆的重叠角度有多大 但我不知道该怎么做 有人有主意吗 Phi ArcTan Sqrt 4 R 2 d 2 d HTH Edit 对于两个不同的半
  • 方程“a + bx = c + dy”的积分解

    在等式中a bx c dy 所有变量都是整数 a b c and d是已知的 我如何找到整体解决方案x and y 如果我的想法是正确的 将会有无限多个解 由最小公倍数分隔b and d 但我只需要一个解决方案 我可以计算其余的 这是一个例
  • 人脸 API DetectAsync 错误

    我想创建一个简单的程序来使用 Microsoft Azure Face API 和 Visual Studio 2015 检测人脸 遵循 https social technet microsoft com wiki contents ar
  • WcfSvcHost 的跨域异常

    对于另一个跨域问题 我深表歉意 我一整天都在与这个问题作斗争 现在已经到了沸腾的地步 我有一个 Silverlight 应用程序项目 SLApp1 一个用于托管 Silverlight SLApp1 Web 的 Web 项目和 WCF 项目
  • 两个类可以使用 C++ 互相查看吗?

    所以我有一个 A 类 我想在其中调用一些 B 类函数 所以我包括 b h 但是 在 B 类中 我想调用 A 类函数 如果我包含 a h 它最终会陷入无限循环 对吗 我能做什么呢 仅将成员函数声明放在头文件 h 中 并将成员函数定义放在实现文
  • C 编程:带有数组的函数

    我正在尝试编写一个函数 该函数查找行为 4 列为 4 的二维数组中的最大值 其中二维数组填充有用户输入 我知道我的主要错误是函数中的数组 但我不确定它是什么 如果有人能够找到我出错的地方而不是编写新代码 我将不胜感激 除非我刚去南方 我的尝
  • 如何在当前 Visual Studio 主机内的 Visual Studio 扩展中调试使用 Roslyn 编译的代码?

    我有一个 Visual Studio 扩展 它使用 Roslyn 获取当前打开的解决方案中的项目 编译它并从中运行方法 程序员可以修改该项目 我已从当前 VisualStudioWorkspace 成功编译了 Visual Studio 扩
  • C 函数 time() 如何处理秒的小数部分?

    The time 函数将返回自 1970 年以来的秒数 我想知道它如何对返回的秒数进行舍入 例如 对于100 4s 它会返回100还是101 有明确的定义吗 ISO C标准没有说太多 它只说time 回报 该实现对当前日历时间的最佳近似 结
  • C++ 中的 include 和 using 命名空间

    用于使用cout 我需要指定两者 include
  • C# 中最小化字符串长度

    我想减少字符串的长度 喜欢 这串 string foo Lorem ipsum dolor sit amet consectetur adipiscing elit Aenean in vehicula nulla Phasellus li
  • DotNetZip:如何提取文件,但忽略zip文件中的路径?

    尝试将文件提取到给定文件夹 忽略 zip 文件中的路径 但似乎没有办法 考虑到其中实现的所有其他好东西 这似乎是一个相当基本的要求 我缺少什么 代码是 using Ionic Zip ZipFile zf Ionic Zip ZipFile
  • Mono 应用程序在非阻塞套接字发送时冻结

    我在 debian 9 上的 mono 下运行一个服务器应用程序 大约有 1000 2000 个客户端连接 并且应用程序经常冻结 CPU 使用率达到 100 我执行 kill QUIT pid 来获取线程堆栈转储 但它总是卡在这个位置
  • 现代编译器是否优化乘以 1 和 -1

    如果我写 template

随机推荐

  • 什么是边缘计算(Edge AI)?

    什么是边缘计算 Edge AI 道翰天琼认知智能机器人平台API接口大脑为您揭秘 边缘AI发源于边缘计算 边缘计算也称为边缘处理 是一种将服务器放置在本地设备附近网络技术 这有助于降低系统的处理负载 解决数据传输的延迟问题 这样的处理是在传
  • KeyError: 'Spider not found: xxxx'

    保证确实由有Spider的情况下 可以查看你的scrapy cfg文件是否丢失
  • android studio 设置model设置为library

    如图所示 我的项目里面是两个model 我现在把第二个flowlayout设置为library来用 在App中引用flowlayout 为了防止今后忘记 特此标注一下 首先第一步 找到我们要做library的model的build文件 我这
  • element步骤条增加锚点的实现

    element的步骤条默认样式是无法点击的 需求中有点击步骤条 页面滚动到特定锚点需求 实现如下
  • 【云原生之Docker实战】使用Docker部署PhotoPrism照片管理系统

    云原生之Docker实战 使用Docker部署PhotoPrism照片管理系统 一 PhotoPrism介绍 1 PhotoPrism简介 2 PhotoPrism特点 二 检查宿主机系统版本 三 检查本地docker环境 1 检查dock
  • jumpserver堡垒机 (资源)

    23 5 jumpserver介绍 官网www jumpserver org 跳板机概述 跳板机就是一台服务器 开发戒运维人员在维护过程中首先要统一登录到这台服务器 然后再登录到目标 设备迚行维护和操作 堡垒机概述 堡垒机 即在一个特定的网
  • (附源码)springboot高校宿舍交电费系统 毕业设计031552

    Springboot高校宿舍交电费系统 摘 要 科技进步的飞速发展引起人们日常生活的巨大变化 电子信息技术的飞速发展使得电子信息技术的各个领域的应用水平得到普及和应用 信息时代的到来已成为不可阻挡的时尚潮流 人类发展的历史正进入一个新时代
  • 关于Python爬虫Scrapy在高并发下DNS查找失败解决方案

    使用场景 检测80w URL 可否打开 配置 高端配置 20 进程 500 CONCURRENT REQUESTS 运行一段时间后会有DNSLookup什么的错误 也就是查找超时 但是在浏览器里可以打开这个网页 首先做一些可能的无用功 爬虫
  • LeetCode——剑指 Offer 39. 数组中出现次数超过一半的数字

    剑指 Offer 39 数组中出现次数超过一半的数字 题目 数组中有一个数字出现的次数超过数组长度的一半 请找出这个数字 你可以假设数组是非空的 并且给定的数组总是存在多数元素 示例 1 输入 1 2 3 2 2 2 5 4 2 输出 2
  • Ajax简要分析使用

    先抛出一般结构 ajax type get url Stu Servlet data type select student id stu id message p success function data alert data 当然是j
  • Ubuntu22.04使用中文输入法

    安装的时候选择了英文安装 之后切换到中文 忘记还要写中文注释 发现在语言设置里不能添加输入法 仔细找了以下发现输入法的设置改到了键盘设置里 网络上查到的大部分都是老版本的ubuntu 这个是2204版本 输入法设置位置不同
  • 闪回事务查询+闪回事务查询案例

    闪回事务查询 1闪回事务查询是闪回版本查询的一个扩充 2闪回事务查询可以审计某个事务或者撤销一个已经提交的事务 闪回事务查询案例 测试数据 create table sct4 id number 4 name varchar2 20 ins
  • uos,qt,linuxdeployqt,qt-installer-framework, 生成安装包的记录

    注 使用源码生成安装包的环境要求 已安装QT v5 5 24 DTK QTcreator linuxdeployqt qt installer framework v5 9 的UOS v20 1 打开QTcreator 新建项目 2 选择侧
  • python随机生成验证码,数字+大小写字母

    ASCII码的对照链接 大写字母的十进制范围是 65 91 小写字母的十进制范围是 97 123 数字的十进制范围是 48 58 思路 1 先在空链表中添加大小写字母和数字 2 从列表中随机选择四个验证码 3 将列表转化成字符串输出 代码如
  • python 进行排序的两种方式 sort和sorted

    方法1 用List的成员函数sort进行排序 方法2 用内建函数sorted进行排序 sort函数定义 sort cmp None key None reverse False sorted函数定义 sorted iterable cmp
  • Cannot invoke “String.equalsIgnoreCase(String)“ because “code“ is null

    问题 同时开启多个项目 端口号不一致导致项目前后端错乱匹配 解决办法 后端 ruoyi admin下的application yml中的port 端口号 前端 vue config js里的port 端口号修改一致
  • cpp 解析HTML之 htmlcxx

    html与xml格式上比较相似 但xml不并一定能支持html的解析 这里介绍一个c 解析html的开源项目 htmlcxx 一 代码示例 1 项目源码下载之后 使用vs打开即可 默认为生成 lib静态库及MTd模式 可以在属性中修改指定为
  • httprunner测试框架3--har2case录制脚本

    har2case录制脚本 录制脚本 只是一个过渡 可以将录制的 har脚本快速转化成httprunner脚本文件 不能依靠录制 har2case可以将 har文件转化成yaml格式或者json格式的httprunner的脚本 可以借助fid
  • java代码kafka初始化producer和consumer

    目录 一 初始化producer对象 序列化消息 生产者发送消息的三种方式 kafka生产者其它详细知识 二 初始化consumer对象 反序列化消息 consumer取消订阅的方式consumer unsubscribe 使用自定义的序列
  • 回溯法解决地图填色问题

    目录 回溯法 最大度优先 最少可选颜色优先 向前探测 随机产生不同规模的图 分析算法效率与图规模的关系 四色 回溯法 回溯法的基本思想是采用递归和深度优先搜索的方法 尝试在一组可能的解中搜索出符合要求的解 在搜索过程中 若发现当前所选的方案