neo4j是一套noSQL的圖形數(shù)據(jù)庫充坑,適合存儲點减江、線、面等圖數(shù)據(jù)結(jié)構(gòu)捻爷。
基于Java開發(fā)辈灼,缺點是占用大量內(nèi)存。
適配Java也榄、Python巡莹、ruby等語言。
適用場景:
Social Network(社交網(wǎng)絡(luò),企業(yè)用戶比如Linkedin)
Network and IT Operation(網(wǎng)絡(luò)或者運維)
Fraud Detection (反詐騙)
Graph Based Search(圖算法降宅,類似于我之前研究的拓撲算法骂远,ebay把這個應(yīng)用在快遞分發(fā)系統(tǒng))
Identity and Access(登陸信息驗證,挪威電信Telenor公司在用腰根,我的前東家甲方公司)
Master Data Management(主數(shù)據(jù)管理激才,這個就不太清楚了,pitney bowes供應(yīng)鏈公司)
Recommendation Engine(商品評論引擎唠雕,Walmart德國沃爾瑪?shù)入娚滔到y(tǒng))
官網(wǎng)地址:https://neo4j.com/
Windows環(huán)境下載exe安裝贸营,用的是免費社區(qū)版
啟動服務(wù),簡單的Java Swing程序
登陸試玩岩睁,引導(dǎo)界面還是蠻不錯的:
用了官方的一套demo:
import org.neo4j.driver.v1.*;
import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
import static org.neo4j.driver.v1.Values.parameters;
public class Social {
public static void main(String...args) {
Config noSSL = Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig();
Driver driver = GraphDatabase.driver("bolt://localhost",AuthTokens.basic("neo4j","123456"),noSSL); // <password>
try (Session session = driver.session()) {
List data =
asList(asList("Jim","Mike"),asList("Jim","Billy"),asList("Anna","Jim"),
asList("Anna","Mike"),asList("Sally","Anna"),asList("Joe","Sally"),
asList("Joe","Bob"),asList("Bob","Sally"));
String insertQuery = "UNWIND {pairs} as pair " +
"MERGE (p1:Person {name:pair[0]}) " +
"MERGE (p2:Person {name:pair[1]}) " +
"MERGE (p1)-[:KNOWS]-(p2);";
session.run(insertQuery, Collections.<String, Object>singletonMap("pairs",data)).consume();
StatementResult result;
String foafQuery =
" MATCH (person:Person)-[:KNOWS]-(friend)-[:KNOWS]-(foaf) "+
" WHERE person.name = {name} " +
" AND NOT (person)-[:KNOWS]-(foaf) " +
" RETURN foaf.name AS name ";
result = session.run(foafQuery, parameters("name","Joe"));
while (result.hasNext()) System.out.println(result.next().get("name"));
String commonFriendsQuery =
"MATCH (user:Person)-[:KNOWS]-(friend)-[:KNOWS]-(foaf:Person) " +
" WHERE user.name = {from} AND foaf.name = {to} " +
" RETURN friend.name AS friend";
result = session.run(commonFriendsQuery, parameters("from","Joe","to","Sally"));
while (result.hasNext()) System.out.println(result.next().get("friend"));
String connectingPathsQuery =
"MATCH path = shortestPath((p1:Person)-[:KNOWS*..6]-(p2:Person)) " +
" WHERE p1.name = {from} AND p2.name = {to} " +
" RETURN [n IN nodes(path) | n.name] as names";
result = session.run(connectingPathsQuery, parameters("from","Joe","to","Billy"));
while (result.hasNext()) System.out.println(result.next().get("names"));
}
}
}
MAVEN地址
圖數(shù)據(jù)庫相關(guān)書籍
《圖數(shù)據(jù)庫(第2版)》