Apache spark 在图形框架中实现自定义算法
我想在使用pyspark 2.3运行的GraphFrame的图上运行双连通图算法 我意识到所有内置算法都是在Scala中使用GraphX运行的 有没有办法在scala-GraphX中实现双连接算法,然后在GraphFrames对象上调用它Apache spark 在图形框架中实现自定义算法,apache-spark,pyspark,spark-graphx,connected-components,graphframes,Apache Spark,Pyspark,Spark Graphx,Connected Components,Graphframes,我想在使用pyspark 2.3运行的GraphFrame的图上运行双连通图算法 我意识到所有内置算法都是在Scala中使用GraphX运行的 有没有办法在scala-GraphX中实现双连接算法,然后在GraphFrames对象上调用它 有人熟悉这样的解决方案吗 不,我不熟悉任何解决方案;我相信这些程序不可能完成,最好的办法是用JavaScript编写自己的程序(最好),如果你想要简单的3D绘图,请查看three.js,如果不想,只需使用SVG绘制各种形状,甚至纯CSS,下面是一些JavaSc
有人熟悉这样的解决方案吗 不,我不熟悉任何解决方案;我相信这些程序不可能完成,最好的办法是用JavaScript编写自己的程序(最好),如果你想要简单的3D绘图,请查看three.js,如果不想,只需使用SVG绘制各种形状,甚至纯CSS,下面是一些JavaScript代码,用于从两点创建线条,只需将其与点数组一起使用即可绘制图形(这里包括两个函数/类,一个是用于创建DOM节点的辅助函数): 然后使用line函数绘制各种线(从点到点):
var Grapher = new (function() {
this.el = function(opts) {
if(!svgList.split(" ").find(x => x == opts.tag)) {
this.node = document.createElement(opts.tag || "div");
} else {
this.node = document.createElementNS('http://www.w3.org/2000/svg', opts.tag);
}
for(var k in opts) {
if(k == "style") {
for(var s in opts[k]) {
this.node.style[s] = opts[k][s];
}
} else if(k != "parent"){
this.node[k] = opts[k];
}
}
this.setAttrs = (attrs) => {
for(var k in attrs) {
this.node.setAttribute(k, attrs[k]);
}
};
this.getAttr = (at) => {
return this.node.getAttribute(at);
};
this.setStyle = (stl) => {
for(var k in stl) {
this.node.style[k] = stl[k];
}
}
var attr = opts.attr || {};
this.setAttrs(attr);
var optsPar = opts.parent;
var par = null;
if(optsPar) {
if(optsPar.constructor == String) {
par = f("#" + optsPar);
} else if(optsPar instanceof Element) {
par = optsPar;
}
}
this.parent = par || document.body || {appendChild: (d) => {}};
this.parent.appendChild(this.node);
};
this.line = (opts) => {
var start = opts.start || {x:0,y:0},
end = opts.end || {x:0,y:0},
rise = end.y - start.y,
run = end.x - start.x,
slope = rise / run,
boxWidth = Math.sqrt((rise * rise) + (run * run)),
degAngle = Math.atan(slope) * 180 / Math.PI,
thickness = opts.thickness || "2",
holder = new this.el({
attr: {
class:"lineBox"
},
style: {
position:"absolute",
left:start.x,
top:start.y,
width:`${boxWidth}px`,
height:`${thickness}px`,
transform:`rotate(${degAngle}deg)`,
transformOrigin:"0 0",
background:opts.texture || "black"
},
parent:opts.parent
});
}
})();
Grapher.line({
start: {
x:2,
y:200
}
end: {
x:10,
y:500
}
});