我想使用Java API来操作远程服务器上的图形,服务器实际上在localhost中托管.我用来连接服务器的代码是:
JanusGraphFactory.Builder b = JanusGraphFactory.build();
b.set("hosts", "[localhost]");
JanusGraph graph = b.open();
Run Code Online (Sandbox Code Playgroud)
但是在我运行程序之后,它抛出了这样的异常:
线程"main"中的异常java.lang.IllegalStateException:需要设置配置值:root.storage.backend
那么如何使用Java API连接到远程JanusGraph服务器?
我使用gremlin-console(janusgraph)远程连接到gremlin服务器,但是当我创建一个变量并访问它时,它不起作用.我的最终目标是使用gremlin-console创建索引...
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server -
[localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin> a = "b"
==>b
gremlin> a
No such property: a for class: Script3
Type ':help' or ':h' for help.
Run Code Online (Sandbox Code Playgroud) 我有两种方法几乎可以做同样的事情,方法签名在这里:
def setProperty[T: TypeTag](name: String, value: T): Unit
Run Code Online (Sandbox Code Playgroud)
def setProperty[T: TypeTag](name: String, value: List[T]): Unit
Run Code Online (Sandbox Code Playgroud)
我只能声明两个方法,因为我想捕获List的通用参数,而第一个方法则不能。我希望值是完全名单实例,而不是一般的牛逼。如何将这两种方法合并为一个?
我想使用 ANTLR 的访问者模式构建一个简单的规则引擎,但是当它带有替代令牌时,我很困惑如何获取哪个替代令牌。谁能帮我吗?(抱歉我的英语不好)
grammar RuleExpression;
expression: '(' Operator arg* ')';
arg: STRING|INTEGER|BOOLEAN|expression;
STRING: '"' .+ '"';
INTEGER: [0-9]+;
BOOLEAN: 'true'|'false';
Operator: [a-zA-Z]+[0-9]*;
WS : [ \t\r\n]+ -> skip;
Run Code Online (Sandbox Code Playgroud)
如何知道 arg 是 STRING、INTEGER、BOOLEAN 或表达式?
在第3章中,有一个名为"MySecond.hs"的例子,我真正不理解的是这样的代码:
safeSecond :: [a] -> Maybe a
Run Code Online (Sandbox Code Playgroud)
它总是在文件的第一行,并删除它不会造成任何麻烦.任何人都可以通过这意味着什么来启发我?我只是任何函数式编程语言的新手.
我使用0,1数组实现了一个迷宫.入口和目标在迷宫中得到修复.进入始终是迷宫的0,0点.目标始终是迷宫的m-1,n-1点.我现在使用广度优先搜索算法,但速度不够好.特别适用于大型迷宫(100*100左右).有人可以帮我解决这个算法吗?
这是我的解决方案:
queue = []
position = start_node
mark_tried(position)
queue << position
while(!queue.empty?)
p = queue.shift #pop the first element
return true if maze.goal?(p)
left = p.left
visit(queue,left) if can_visit?(maze,left)
right = p.right
visit(queue,right) if can_visit?(maze,right)
up = p.up
visit(queue,up) if can_visit?(maze,up)
down = p.down
visit(queue,down) if can_visit?(maze,down)
end
return false
Run Code Online (Sandbox Code Playgroud)
can_visit?方法检查节点是否在迷宫内,节点是否被访问,节点是否被阻塞.
janusgraph ×2
tinkerpop ×2
algorithm ×1
antlr ×1
compilation ×1
generics ×1
gremlin ×1
haskell ×1
java ×1
scala ×1
tinkerpop3 ×1