HK1254034B - Cluster-based random walk method, device and equipment for random walk - Google Patents
Cluster-based random walk method, device and equipment for random walk Download PDFInfo
- Publication number
- HK1254034B HK1254034B HK18112979.0A HK18112979A HK1254034B HK 1254034 B HK1254034 B HK 1254034B HK 18112979 A HK18112979 A HK 18112979A HK 1254034 B HK1254034 B HK 1254034B
- Authority
- HK
- Hong Kong
- Prior art keywords
- dimensional array
- node
- cluster
- identifiers
- nodes
- Prior art date
Links
Description
技术领域Technical Field
本说明书涉及计算机软件技术领域,尤其涉及随机游走、基于集群的随机游走方法、装置以及设备。This specification relates to the field of computer software technology, and in particular to random walks, cluster-based random walk methods, devices, and equipment.
背景技术Background Art
随着计算机和互联网技术的迅速发展,很多业务都可以在网上进行,图计算是处理社交方面的网上业务的一种常用手段。With the rapid development of computer and Internet technologies, many businesses can be conducted online. Graph computing is a common method for processing online social businesses.
例如,对于社交风控业务中的账户欺诈识别:每个用户分别作为一个节点,若两个用户之间存在转账关系,则对应的两个节点之间存在一条边,边可以是无向的,也可以是根据转账方向定义了方向的;以此类推,可以得到包含多个节点和多条边的图数据,进而基于图数据进行图计算以实现风控。For example, for account fraud identification in social risk control business: each user is regarded as a node. If there is a transfer relationship between two users, there is an edge between the corresponding two nodes. The edge can be undirected or have a direction defined according to the transfer direction; by analogy, graph data containing multiple nodes and multiple edges can be obtained, and then graph calculations can be performed based on the graph data to achieve risk control.
随机游走算法是图计算中比较基础和重要的一环,其为上层复杂算法提供支持。在现有技术中,一般采用这样的随机游走算法:在数据库中随机读取图数据包含的一个节点,再继续在该数据库中随机读取该节点的一个相邻节点,以此类推,实现在图数据中的随机游走。Random walk algorithms are a fundamental and important part of graph computing, providing support for higher-level complex algorithms. Conventional techniques typically employ a random walk algorithm that randomly reads a node from a database, then randomly reads an adjacent node from the database, and so on, to implement a random walk within the graph.
基于现有技术,需要能够应用于大规模图数据的更为高效的随机游走方案。Based on existing technologies, a more efficient random walk scheme that can be applied to large-scale graph data is needed.
发明内容Summary of the Invention
本说明书实施例提供随机游走、基于集群的随机游走方法、装置以及设备,用以解决如下技术问题:需要能够应用于大规模图数据的更为高效的随机游走方案。The embodiments of this specification provide random walks, cluster-based random walk methods, devices, and equipment to solve the following technical problems: a more efficient random walk solution that can be applied to large-scale graph data is needed.
为解决上述技术问题,本说明书实施例是这样实现的:To solve the above technical problems, the embodiments of this specification are implemented as follows:
本说明书实施例提供的一种基于集群的随机游走方法,包括:The embodiments of this specification provide a cluster-based random walk method, including:
所述集群获取图数据包含的各节点的信息;The cluster obtains information of each node included in the graph data;
根据所述各节点的信息,生成二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;Generate a two-dimensional array based on the information of each node, where each row of the two-dimensional array includes an identifier of an adjacent node of the node;
根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A random sequence is generated based on the two-dimensional array, where the random sequence reflects a random walk in the graph data.
本说明书实施例提供的一种随机游走方法,包括:The embodiments of this specification provide a random walk method, including:
获取根据图数据包含的各节点的信息生成的二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;Obtain a two-dimensional array generated according to information of each node included in the graph data, wherein each row of the two-dimensional array includes an identifier of an adjacent node of the node;
根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A random sequence is generated based on the two-dimensional array, where the random sequence reflects a random walk in the graph data.
本说明书实施例提供的一种基于集群的随机游走装置,所述装置属于所述集群,包括:An embodiment of this specification provides a cluster-based random walk device, which belongs to the cluster and includes:
获取模块,获取图数据包含的各节点的信息;The acquisition module obtains the information of each node contained in the graph data;
第一生成模块,根据所述各节点的信息,生成二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;A first generating module generates a two-dimensional array according to the information of each node, wherein each row of the two-dimensional array includes an identifier of an adjacent node of the node;
第二生成模块,根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。The second generating module generates a random sequence according to the two-dimensional array, where the random sequence reflects the random walk in the graph data.
本说明书实施例提供的一种随机游走装置,包括:The embodiments of this specification provide a random walk device, comprising:
获取模块,获取根据图数据包含的各节点的信息生成的二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;An acquisition module, which acquires a two-dimensional array generated according to information of each node contained in the graph data, wherein each row of the two-dimensional array includes an identifier of an adjacent node of the node;
生成模块,根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A generating module generates a random sequence according to the two-dimensional array, where the random sequence reflects a random walk in the graph data.
本说明书实施例提供的一种基于集群的随机游走设备,所述设备属于所述集群,包括:An embodiment of this specification provides a cluster-based random walk device, wherein the device belongs to the cluster and includes:
至少一个处理器;以及,at least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
获取图数据包含的各节点的信息;Get the information of each node contained in the graph data;
根据所述各节点的信息,生成二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;Generate a two-dimensional array based on the information of each node, where each row of the two-dimensional array includes an identifier of an adjacent node of the node;
根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A random sequence is generated based on the two-dimensional array, where the random sequence reflects a random walk in the graph data.
本说明书实施例提供的一种随机游走设备,包括:The embodiments of this specification provide a random walk device, including:
至少一个处理器;以及,at least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
获取根据图数据包含的各节点的信息生成的二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;Obtain a two-dimensional array generated according to information of each node included in the graph data, wherein each row of the two-dimensional array includes an identifier of an adjacent node of the node;
根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A random sequence is generated based on the two-dimensional array, where the random sequence reflects a random walk in the graph data.
本说明书实施例采用的上述至少一个技术方案能够达到以下有益效果:有利于减少对原始保存图数据的数据库的访问,二维数组在生成后无需依赖该数据库,通过二维数组能够快速索引节点的相邻节点,该方案能够适用于大规模图数据且效率较高,在基于集群实施该方案的情况下,还能够进一步地提高效率。At least one of the above-mentioned technical solutions adopted in the embodiments of this specification can achieve the following beneficial effects: it is conducive to reducing the access to the database that originally stores the graph data, the two-dimensional array does not need to rely on the database after generation, and the adjacent nodes of the node can be quickly indexed through the two-dimensional array. This solution can be applied to large-scale graph data and is highly efficient. When this solution is implemented based on a cluster, the efficiency can be further improved.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
图1为本说明书的方案在一种实际应用场景下涉及的一种整体架构示意图;FIG1 is a schematic diagram of an overall architecture of the solution of this specification in a practical application scenario;
图2为本说明书实施例提供的一种基于集群的随机游走方法的流程示意图;FIG2 is a flow chart of a cluster-based random walk method provided in an embodiment of this specification;
图3为本说明书实施例提供的一种实际应用场景下,基于集群的二维数组生成流程示意图;FIG3 is a schematic diagram of a cluster-based two-dimensional array generation process in an actual application scenario provided by an embodiment of this specification;
图4为本说明书实施例提供的一种实际应用场景下,基于集群的随机序列生成流程示意图;FIG4 is a schematic diagram of a cluster-based random sequence generation process in an actual application scenario provided by an embodiment of this specification;
图5为本说明书实施例提供的一种随机游走方法的流程示意图;FIG5 is a schematic diagram of a flow chart of a random walk method provided in an embodiment of this specification;
图6为本说明书实施例提供的对应于图2的一种基于集群的随机游走装置的结构示意图;FIG6 is a schematic structural diagram of a cluster-based random walk device corresponding to FIG2 provided in an embodiment of this specification;
图7为本说明书实施例提供的对应于图5的一种随机游走装置的结构示意图。FIG7 is a schematic structural diagram of a random walk device corresponding to FIG5 provided in an embodiment of this specification.
具体实施方式DETAILED DESCRIPTION
本说明书实施例提供随机游走、基于集群的随机游走方法、装置以及设备。The embodiments of this specification provide random walks, cluster-based random walk methods, devices, and equipment.
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本说明书实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to help those skilled in the art better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
本说明书的方案既适用于集群,也适用于单机。在集群下对于大规模图数据的处理效率更高,原因在于:可以拆分任务(比如,数据读取任务、数据同步任务等),进而由集群中的多个机器并行执行被分配给自己的一部分任务。以下各实施例主要基于集群场景进行说明。The solutions in this specification are applicable to both clusters and single machines. Clusters are more efficient for processing large-scale graph data because tasks (e.g., data reading tasks, data synchronization tasks, etc.) can be split up, allowing multiple machines in the cluster to execute their assigned tasks in parallel. The following embodiments are primarily described based on cluster scenarios.
方案涉及的集群可以有一个或者多个,以图1为例,涉及了两个集群。The solution may involve one or more clusters. For example, Figure 1 involves two clusters.
图1为本说明书的方案在一种实际应用场景下涉及的一种整体架构示意图。该整体架构中,主要涉及三部分:服务器集群、工作机集群、数据库。数据库保存有图数据,供集群读取,服务器集群与工作机集群相互配合,根据从数据库读取的数据,实现在图数据中的随机游走。Figure 1 is a schematic diagram of the overall architecture of the solution described in this specification, in a practical application scenario. This architecture primarily involves three components: a server cluster, a worker cluster, and a database. The database stores graph data for the cluster to access. The server cluster and worker cluster work together to implement random walks within the graph data based on the data read from the database.
图1中的架构是示例性的,并非唯一。比如,方案可以涉及一个集群,该集群中包含至少一个调度机和多个工作机;再比如,方案也可以涉及一个工作机集群和一个服务器;等等;方案涉及的机器相互配合,实现在图数据中的随机游走。The architecture in Figure 1 is illustrative and not exclusive. For example, a solution could involve a cluster consisting of at least one scheduler and multiple workers; another could involve a cluster of workers and a server; and so on. The machines involved in the solution work together to implement random walks on the graph data.
下面对本说明书的方案进行详细说明。The scheme of this manual is described in detail below.
图2为本说明书实施例提供的一种基于集群的随机游走方法的流程示意图。图2中各步骤由集群中的至少一个机器(或者机器上的程序)执行,不同步骤的执行主体可以不同。Figure 2 is a flow chart of a cluster-based random walk method provided by an embodiment of this specification. Each step in Figure 2 is executed by at least one machine in the cluster (or a program on the machine), and different steps may be executed by different entities.
图2中的流程包括以下步骤:The process in Figure 2 includes the following steps:
S202:所述集群获取图数据包含的各节点的信息。S202: The cluster obtains information of each node included in the graph data.
在本说明书实施例中,节点的信息可以包括:节点的标识、节点的相邻节点的标识(以下以此为例)、或者标识以外的能够指示节点的相邻节点的信息等。各节点的信息可以是一次性获取的,也可以是分多次获取的。In the embodiments of this specification, the node information may include: the node identifier, the identifier of the node's neighboring nodes (hereinafter referred to as an example), or information other than the identifier that can indicate the node's neighboring nodes, etc. The information of each node may be obtained at once or in multiple times.
一般地,原始的图数据保存于数据库中,在这种情况下,需要通过访问数据库,读取得到各节点的信息。为了避免重复读取数据增加数据库的负担,集群中的多个机器可以分别读取不重复的一部分节点的信息,进一步地,多个机器可以并行读取数据库,以快速获取节点的信息。Typically, raw graph data is stored in a database. In this case, it is necessary to access the database to retrieve information about each node. To avoid redundant data reads and increasing the database burden, multiple machines in a cluster can each read information about a subset of unique nodes. Furthermore, multiple machines can read the database in parallel to quickly retrieve node information.
例如,可以由工作机集群中的各工作机并行地、分别从数据库读取一部分节点的信息并进行处理,再将处理后得到的数据同步至服务器集群。或者,各工作机也可以将读取的节点的信息,直接同步至服务器集群,由服务器集群进一步地处理。所述处理至少包括生成二维数组。For example, each worker in a worker cluster can concurrently read and process a portion of node information from a database, then synchronize the processed data to a server cluster. Alternatively, each worker can synchronize the read node information directly to the server cluster for further processing. This processing at least includes generating a two-dimensional array.
S204:根据所述各节点的信息,生成二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识。S204: Generate a two-dimensional array according to the information of each node, where each row of the two-dimensional array includes an identifier of an adjacent node of the node.
在本说明书实施例中,二维数组可以视为矩阵,其每行分别为一个一维数组。In the embodiments of this specification, a two-dimensional array can be regarded as a matrix, and each row thereof is a one-dimensional array.
每行可以分别对应一个节点,该行至少包括其对应的节点的相邻节点的标识,每个相邻节点的标识即可以是该行的一个一维数组元素。为了便于索引,该对应的节点的标识自身也可以是该行的一个一维数组元素,比如,该对应的节点的标识为该行的第0个一维数组元素,之后的一维数组元素依次为该节点的各相邻节点的标识。或者,该节点的标识自身可以不包含在该行内,而只是与该行具有关联关系,通过该关联关系能够用该节点的标识索引到该行。Each row may correspond to a node, and the row may include at least the identifiers of the adjacent nodes of the corresponding node, and the identifier of each adjacent node may be a one-dimensional array element of the row. For the convenience of indexing, the identifier of the corresponding node itself may also be a one-dimensional array element of the row. For example, the identifier of the corresponding node is the 0th one-dimensional array element of the row, and the subsequent one-dimensional array elements are the identifiers of the adjacent nodes of the node in turn. Alternatively, the identifier of the node itself may not be included in the row, but may only have an association relationship with the row, and the row can be indexed using the identifier of the node through the association relationship.
根据二维数组以及任意节点的标识,能够快速索引到该节点的任意相邻节点的标识,从而,有利于高效地在图数据中随机游走。Based on the two-dimensional array and the identifier of any node, the identifier of any adjacent node of the node can be quickly indexed, which is conducive to efficient random walking in the graph data.
为了便于索引,各节点的标识优选地为数字。比如,用各节点的标识大小定义各节点的顺序,从0开始计数,顺序最先的节点的标识为0、顺序第二的节点的标识为1,依次类推。以下各实施例基于该例中的定义进行说明。For ease of indexing, the identifiers of each node are preferably numbers. For example, the order of each node is defined by the size of the identifiers of each node, starting from 0, with the identifier of the first node being 0, the identifier of the second node being 1, and so on. The following embodiments are described based on the definition in this example.
当然,若节点原本的标识并非数字,也可以基于一一映射的规则,将所述原本的标识映射为数字后,作为节点的标识用于生成二维数组。Of course, if the original identifier of the node is not a number, the original identifier can also be mapped to a number based on a one-to-one mapping rule and used as the node identifier to generate a two-dimensional array.
S208:根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。S208: Generate a random sequence according to the two-dimensional array, where the random sequence reflects a random walk in the graph data.
在本说明书实施例中,随机序列为多个节点的标识构成的序列,各标识在该随机序列中的顺序即为随机游走顺序,随机序列的最大长度一般由预定的随机游走步数决定。In the embodiment of this specification, the random sequence is a sequence composed of identifiers of multiple nodes. The order of the identifiers in the random sequence is the random walk order. The maximum length of the random sequence is generally determined by a predetermined number of random walk steps.
在得到二维数组后,可以相互独立地多次执行步骤S206,进而得到多个相互独立的随机序列。比如,各工作机分别根据二维数组,生成一个或者多个随机序列。After obtaining the two-dimensional array, step S206 can be performed multiple times independently to obtain multiple independent random sequences. For example, each working machine generates one or more random sequences based on the two-dimensional array.
通过图2的方法,有利于减少对原始保存图数据的数据库的访问,二维数组在生成后无需依赖该数据库,通过二维数组能够快速索引节点的相邻节点,该方案能够适用于大规模图数据且效率较高,由于基于集群实施该方法,因此,还能够进一步地提高效率。The method of Figure 2 is helpful in reducing the access to the database that originally stores the graph data. After the two-dimensional array is generated, it does not need to rely on the database. The two-dimensional array can quickly index the adjacent nodes of the node. This solution is applicable to large-scale graph data and is highly efficient. Since this method is implemented based on a cluster, it can further improve efficiency.
基于图2的方法,本说明书实施例还提供了该方法的一些具体实施方案,以及扩展方案,下面以图1中的架构为例,进行说明。Based on the method of FIG2 , the embodiments of this specification also provide some specific implementation plans and extension plans of the method, which will be described below using the architecture in FIG1 as an example.
在本说明书实施例中,如前所述,所述集群可以包括服务器集群和工作机集群,对于步骤S202,所述集群获取图数据包含的各节点的信息,具体可以包括:In the embodiment of this specification, as described above, the cluster may include a server cluster and a worker cluster. For step S202, the cluster obtains information of each node included in the graph data, which may specifically include:
所述工作机集群从数据库读取图数据包含的各节点的相邻节点的标识,其中,每个工作机读取一部分节点的相邻节点的标识。需要说明的是,若对于工作机集群,节点的标识本身也是未知的,则工作机集群可以读取节点的标识,并根据节点的标识(在数据库中作为主键),读取节点的相邻节点的标识。The worker cluster reads the identifiers of the neighboring nodes of each node contained in the graph data from the database, wherein each worker reads the identifiers of the neighboring nodes of a portion of the nodes. It should be noted that if the identifier of the node itself is also unknown to the worker cluster, the worker cluster can read the identifier of the node and, based on the identifier of the node (which serves as the primary key in the database), read the identifiers of the neighboring nodes of the node.
例如,假定有标识分别为0~4的5个节点。工作机集群包括工作机0、工作机1、工作机2,每个工作机分别从数据库读取一部分节点的相邻节点的标识;比如,工作机0读取节点1的相邻节点的标识(分别为0、2),以及节点2的标识(分别为1、3、4);工作机1读取节点0的相邻节点的标识(为1);工作机2读取节点3的相邻节点的标识(分别为2、4),以及节点4的标识(分别为2、3)。For example, assume there are five nodes with IDs 0 to 4. The worker cluster includes worker 0, worker 1, and worker 2. Each worker reads the IDs of some of the nodes' neighboring nodes from the database. For example, worker 0 reads the IDs of node 1's neighboring nodes (0 and 2), and node 2's IDs (1, 3, and 4). Worker 1 reads the ID of node 0's neighboring nodes (1). Worker 2 reads the IDs of node 3's neighboring nodes (2 and 4), and node 4's IDs (2 and 3).
在本说明书实施例中,各工作机可以根据自己读取标识的相邻节点及其对应节点的标识,生成非全量的二维数组。In the embodiment of the present specification, each working machine may generate a non-complete two-dimensional array based on the identifiers of adjacent nodes and their corresponding nodes read by itself.
进一步地,工作机集群可以将这些非全量的二维数组同步给服务器集群。从而,服务器集群能够得到由这些非全量的二维数组构成的全量的二维数组,具体地:服务器集群可以通过专门整合(比如,拆分二维数组、合并二维数组等)这些非全量的二维数组,得到全量的二维数组;也可以不专门整合而只是在工作机集群同步完毕后,将同步得到的全部数据视为一个整体,即全量的二维数组。服务器集群中的各服务机可以分别保存全量的二维数组,也可以只保存全量的二维数组的一部分。Furthermore, the worker cluster can synchronize these partial two-dimensional arrays to the server cluster. Thus, the server cluster can obtain a full two-dimensional array composed of these partial two-dimensional arrays. Specifically, the server cluster can obtain a full two-dimensional array by specifically integrating (for example, splitting the two-dimensional array, merging the two-dimensional array, etc.) these partial two-dimensional arrays. Alternatively, the server cluster can simply treat all synchronized data as a whole, i.e., a full two-dimensional array, without specifically integrating them after the worker cluster is synchronized. Each server in the server cluster can store the full two-dimensional array separately, or only a portion of the full two-dimensional array.
步骤S204所述的二维数组可以是所述全量的二维数组,也可以是所述非全量的二维数组,也可以是对所述全量的二维数组进一步地处理(比如,重排序等)后得到的二维数组,下面各实施例主要以第三种情况为例进行说明。需要说明的是,若是非全量的二维数组,则后续的随机游走相应地在该非全量的二维数组涉及的节点(这些节点只是图数据中的一部分节点)中进行,任意工作机可以根据自己生成的非全量的二维数组,生成随机序列,而未必要依赖于上述同步和服务器集群。The two-dimensional array described in step S204 can be the full two-dimensional array, the incomplete two-dimensional array, or the two-dimensional array obtained by further processing (for example, reordering) the full two-dimensional array. The following embodiments mainly take the third case as an example for explanation. It should be noted that if it is a incomplete two-dimensional array, the subsequent random walk will be carried out accordingly in the nodes involved in the incomplete two-dimensional array (these nodes are only part of the nodes in the graph data). Any working machine can generate a random sequence based on the incomplete two-dimensional array generated by itself, without necessarily relying on the above-mentioned synchronization and server cluster.
对上述同步后的动作继续说明。服务器集群可以进一步地将全量的二维数组再向各工作机分别同步,以便各工作机能够根据全量的二维数组,生成随机序列。上述的第三种情况已经提到,各工作机可以对全量的二维数组进一步处理后,再用于生产随机序列。Continuing with the post-synchronization actions, the server cluster can further synchronize the full two-dimensional array to each worker machine, allowing each worker machine to generate a random sequence based on the full two-dimensional array. As mentioned in the third scenario above, each worker machine can further process the full two-dimensional array before using it to generate a random sequence.
例如,可以根据节点标识顺序,对所述全量的二维数组中的各行进行排序;根据排序后的二维数组,生成随机序列。比如,将节点0及其相邻节点的标识所在的行排在第一行,将节点1及其相邻节点的标识所在的行排在第二行,以此类推;进一步地,还可以将第一行中节点0的标识剔除,只保留其相邻节点的标识,并建立节点0与处理后的第一行之间的关联关系,以便于后续根据节点0的标识索引第一行中的任意相邻节点的标识,以此类推,处理后的每行中可以只保留相邻节点的标识。For example, the rows in the two-dimensional array of the entire amount can be sorted according to the order of node identifiers; and a random sequence can be generated based on the sorted two-dimensional array. For example, the row containing the identifiers of node 0 and its adjacent nodes can be placed in the first row, the row containing the identifiers of node 1 and its adjacent nodes can be placed in the second row, and so on. Furthermore, the identifier of node 0 in the first row can be removed, and only the identifiers of its adjacent nodes can be retained. An association relationship can be established between node 0 and the first row after processing, so that the identifiers of any adjacent nodes in the first row can be indexed based on the identifier of node 0. Similarly, only the identifiers of adjacent nodes can be retained in each row after processing.
在本说明书实施例中,在处理后各行中,一维数组元素数量相等,该元素数量一般不小于各节点中邻居节点最多的节点的邻居节点数量。对于用邻居节点的标识填不满的行,可以用空元素(也即“null”元素)在行的尾部进行填充。另外,若只有个别节点的邻居节点数量很多,而其他节点的邻居数量相比而言少很多,而也可以参照所述其他节点定义处理后各行中一维数组元素数量,而对于该个别节点的邻居节点,可以只取一部分邻居节点作为该个别节点对应行的元素,以免无谓地浪费大量内存。In the embodiments of the present specification, in each row after processing, the number of one-dimensional array elements is equal, and the number of elements is generally not less than the number of neighbor nodes of the node with the most neighbor nodes in each node. For rows that are not fully filled with the identifiers of neighbor nodes, empty elements (i.e., "null" elements) can be used to fill the tail of the row. In addition, if only an individual node has a large number of neighbor nodes, while the number of neighbors of other nodes is much less, the number of one-dimensional array elements in each row after processing can also be defined with reference to the other nodes, and for the neighbor nodes of the individual node, only a part of the neighbor nodes can be taken as the elements of the row corresponding to the individual node, so as to avoid wasting a lot of memory unnecessarily.
根据上面的说明,本说明书实施例提供的一种实际应用场景下,基于集群的二维数组生成流程示意图,如图3所示。According to the above description, in an actual application scenario provided by an embodiment of this specification, a schematic diagram of a cluster-based two-dimensional array generation process is shown in FIG3 .
在图3中,数据库中的数据表以节点的标识作为主键,记录了各节点的相邻节点的标识,其中,节点0的相邻节点为节点1,节点1的相邻节点为节点0、节点2,节点2的相邻节点为节点1、节点3、节点4,节点3的相邻节点为节点2、节点4、节点4的相邻节点为节点2、节点3。工作机0~2如前所述,优选地可以并行分别从数据库读取一部分节点的相邻节点的标识。In Figure 3, the database table uses the node ID as the primary key and records the IDs of each node's neighboring nodes. Node 0's neighboring node is Node 1, Node 1's neighboring nodes are Node 0 and Node 2, Node 2's neighboring nodes are Node 1, Node 3, and Node 4, Node 3's neighboring nodes are Node 2 and Node 4, and Node 4's neighboring nodes are Node 2 and Node 3. As described above, workers 0-2 can preferably read the IDs of neighboring nodes of some nodes from the database in parallel.
每个工作机根据自己读取的标识,对应地生成非全量的二维数组。工作机0生成的二维数组中包含两行,工作机1生成的二维数组中包含一个行,工作机2生成的二维数组中包含两行。在非全量的二维数组的每行中,既包括节点的标识,也包括该节点的各相邻节点的标识。Each worker generates a partial two-dimensional array based on the identifier it reads. The two-dimensional array generated by worker 0 contains two rows, the two-dimensional array generated by worker 1 contains one row, and the two-dimensional array generated by worker 2 contains two rows. Each row in the partial two-dimensional array includes both the node identifier and the identifiers of each of its neighboring nodes.
工作机集群将生成的各非全量的二维数组都同步至服务器集群,可以看到服务器集群得到了全量的二维数组并分部分保存在服务器0~2中。The worker cluster synchronizes all generated partial two-dimensional arrays to the server cluster. You can see that the server cluster obtains the full two-dimensional array and saves it in parts on servers 0 to 2.
服务器集群将全量的二维数组分别同步给各工作机。则各工作机可以分别独立地对全量的二维数组进行排序和节点剔除处理,得到有序的只包含相邻节点的标识的二维数组,用于生成随机序列。The server cluster synchronizes the full two-dimensional array to each worker machine. Each worker machine can then independently sort and remove nodes from the full two-dimensional array to obtain an ordered two-dimensional array containing only the identifiers of adjacent nodes, which is used to generate a random sequence.
在本说明书实施例中,对于步骤S206,所述根据所述二维数组,生成随机序列,具体可以包括:In the embodiment of this specification, for step S206, generating a random sequence according to the two-dimensional array may specifically include:
所述工作机在所述各节点的标识中,随机确定一个标识,作为目标节点的标识;根据所述目标节点的标识,在所述二维数组中索引得到对应的行,所述对应的行包括所述目标节点的标识,以及所述目标节点的相邻节点的标识;确定所述对应的行包括的相邻节点的标识的数量;随机确定一个小于所述数量的非负整数,并获取所述对应的行包括的第所述非负整数个相邻节点的标识;通过将该第所述非负整数个相邻节点重新作为目标节点进行迭代计算,生成由依次得到的各目标节点的标识构成的随机序列。The working machine randomly determines an identifier among the identifiers of each node as the identifier of the target node; based on the identifier of the target node, indexes the corresponding row in the two-dimensional array, and the corresponding row includes the identifier of the target node and the identifiers of the adjacent nodes of the target node; determines the number of identifiers of the adjacent nodes included in the corresponding row; randomly determines a non-negative integer that is less than the number, and obtains the identifiers of the non-negative integer number of adjacent nodes included in the corresponding row; and generates a random sequence consisting of the identifiers of the target nodes obtained in sequence by re-using the non-negative integer number of adjacent nodes as the target node for iterative calculation.
进一步地沿用图3的例子,结合图4说明。图4为本说明书实施例提供的一种实际应用场景下,基于集群的随机序列生成流程示意图。The example of Figure 3 is further used for explanation in conjunction with Figure 4. Figure 4 is a schematic diagram of a cluster-based random sequence generation process in an actual application scenario provided by an embodiment of this specification.
假定图数据共包含N个节点,第m个所述节点的标识为m,0≤m≤N-1,所述目标节点为第i个节点,所述对应的行为所述二维数组的第i行。所述对应的行为一维数组,所述目标节点的第n个相邻节点的标识为该一维数组的第n个元素,n从0开始计数,所述非负整数记作j。Assume that the graph data contains N nodes, the mth node is identified by m, 0≤m≤N-1, the target node is the i-th node, and the corresponding row is the i-th row of the two-dimensional array. The corresponding row is a one-dimensional array, the nth neighboring node of the target node is identified by the nth element of the one-dimensional array, where n starts counting from 0, and the non-negative integer is denoted by j.
在图5中,N=5,工作机根据服务器集群所同步的全量的二维数组,处理后得到的二维数组(称为相邻节点数组)中相应地包含5行,依次对应于节点0~4,每行分别为一个一维数组,一维数组包括其对应的节点的各相邻节点的标识,不足部分用“null”元素填充。In Figure 5, N=5. The working machine processes the full two-dimensional array synchronized by the server cluster, and the resulting two-dimensional array (called the adjacent node array) contains 5 rows, corresponding to nodes 0 to 4. Each row is a one-dimensional array, and the one-dimensional array includes the identifiers of the adjacent nodes of the corresponding node, and the insufficient part is filled with "null" elements.
工作机随机生成一个属于[0,N-1=4]的整数,即工作机在各节点的标识中,随机确定的目标节点的标识;根据目标节点的标识i,在相邻节点数组索引到第i行(为一维数组);确定该第i行包含的非“null”元素的元素数量;随机确定一个小于该元素数量的非负整数j;通过读取该第i行的第j个元素,得到目标节点的第j个相邻节点的标识。The working machine randomly generates an integer belonging to [0, N-1=4], that is, the working machine randomly determines the identity of the target node among the identifiers of each node; according to the identifier i of the target node, indexes to the i-th row (a one-dimensional array) in the adjacent node array; determines the number of non-"null" elements contained in the i-th row; randomly determines a non-negative integer j that is less than the number of elements; and obtains the identity of the j-th adjacent node of the target node by reading the j-th element in the i-th row.
假定目标节点的标识为2,j=1。则目标节点为节点2,该第i行为[1,3,4],获取的目标节点的第1个相邻节点的标识为该数组的第1个元素,即3。从而,实现从节点2随机游走到节点3,进而将节点3作为目标节点迭代计算,继续随机游走,如此,依次经过的多个节点的标识构成随机序列。Assume the target node's ID is 2, and j = 1. The target node is node 2, and the i-th row is [1, 3, 4]. The ID of the target node's first neighboring node is the first element of the array, 3. This allows a random walk from node 2 to node 3, and then iterative calculations using node 3 as the target node, continuing the random walk. Thus, the IDs of the multiple nodes passed through form a random sequence.
在图4中,预先设定随机游走步数为8,批数为5。用矩阵进行表示,随机游走步数比如为该矩阵的列数,批数为该矩阵的行数,该矩阵的每一行可以存储一个随机序列。In Figure 4, the number of random walk steps is preset to 8 and the number of batches is preset to 5. Represented by a matrix, the number of random walk steps is, for example, the number of columns of the matrix, and the number of batches is the number of rows of the matrix. Each row of the matrix can store a random sequence.
随机游走步数定义了一个随机序列的最大长度,每当随机序列达到该最大长度时,可以不依赖该随机序列而开始生成下一个随机序列。The number of random walk steps defines the maximum length of a random sequence. Whenever a random sequence reaches the maximum length, the next random sequence can be generated without relying on the current random sequence.
批数定义了每个工作机在向数据库写入已生成前,生成随机序列的最大个数,到达该最大个数时,工作机可以将自己已生成未写入的多个随机序列(表示为对应的矩阵)写入数据库。比如,图5中工作机2当前已生成未写入的随机序列已经到达最大个数5,则可以将对应的矩阵写入数据库。The batch size defines the maximum number of random sequences each worker can generate before writing the generated sequences to the database. When this maximum number is reached, the worker can write its previously generated random sequences (represented by the corresponding matrices) to the database. For example, in Figure 5, if worker 2 has reached the maximum number of generated random sequences (5), it can write the corresponding matrices to the database.
以图4中工作机0生成的第一个随机序列(3,4,3,2,4,2,3,2)为例,该随机序列即表示依次经过下列节点的随机游走过程:节点3、节点4、节点3、节点2、节点4、节点2、节点3、节点2。Taking the first random sequence (3, 4, 3, 2, 4, 2, 3, 2) generated by worker machine 0 in Figure 4 as an example, this random sequence represents a random walk process passing through the following nodes in sequence: node 3, node 4, node 3, node 2, node 4, node 2, node 3, node 2.
进一步地,还可以预先设定阈值,用于限定整个工作机集群生成的随机序列的最大总数量。当到达该设定阈值时,各工作机可以停止生成随机序列。Furthermore, a threshold value may be pre-set to limit the maximum total number of random sequences generated by the entire worker cluster. When the threshold value is reached, each worker may stop generating random sequences.
另外,在实际应用中,工作机集群中的某些工作机可能会出现异常,导致之前用于生成随机序列的二维数组丢失。比如,若工作机将该二维数组只存储在内存中,则宕机后内存中的数据会丢失。在这种情况下,当这些工作机恢复正常时,可以从服务器集群重新获取全量的二维数组并进行处理后用于生成随机序列。图4中通过工作机2示出了这种情况。Furthermore, in actual applications, some workers in a worker cluster may experience anomalies, resulting in the loss of the two-dimensional array previously used to generate the random sequence. For example, if a worker only stores the two-dimensional array in memory, the data in memory will be lost after the outage. In this case, when these workers return to normal operation, the full two-dimensional array can be retrieved from the server cluster, processed, and used to generate the random sequence. Figure 4 illustrates this situation using worker 2.
上面主要是基于集群场景,对本说明书的方案进行说明的,本说明书的方案也可以脱离集群场景。比如,基于同样的思路,本说明书实施例还提供了一种随机游走方法的流程示意图,如图5所示。The above mainly describes the solution of this specification based on the cluster scenario, and the solution of this specification can also be separated from the cluster scenario. For example, based on the same idea, the embodiment of this specification also provides a flow chart of a random walk method, as shown in Figure 5.
图5中的流程的执行主体可以是单一的计算设备,也可以是多个计算设备,该流程包括以下步骤:The execution subject of the process in FIG5 can be a single computing device or multiple computing devices. The process includes the following steps:
S502:获取根据图数据包含的各节点的信息生成的二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识。S502: Obtain a two-dimensional array generated according to information of each node included in the graph data, where each row of the two-dimensional array includes an identifier of an adjacent node of the node.
在步骤S502中,二维数组具体由谁生成,本申请并不做限定。一般地,只要图数据未发生变化,根据该图数据已生成的二维数组可以一直复用。In step S502, the specific person who generates the two-dimensional array is not limited in this application. Generally, as long as the graph data does not change, the two-dimensional array generated based on the graph data can be reused.
S504:根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。S504: Generate a random sequence according to the two-dimensional array, where the random sequence reflects a random walk in the graph data.
基于同样的思路,本说明书实施例还提供了上面各方法的对应装置,如图6、图7所示。Based on the same idea, the embodiments of this specification also provide corresponding devices for the above methods, as shown in Figures 6 and 7.
图6为本说明书实施例提供的对应于图2的一种基于集群的随机游走装置的结构示意图,该装置属于所述集群,包括:FIG6 is a schematic structural diagram of a cluster-based random walk device corresponding to FIG2 provided in an embodiment of this specification. The device belongs to the cluster and includes:
获取模块601,获取图数据包含的各节点的信息;Acquisition module 601, acquiring information of each node contained in the graph data;
第一生成模块602,根据所述各节点的信息,生成二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;A first generating module 602 generates a two-dimensional array based on the information of each node, wherein each row of the two-dimensional array includes an identifier of an adjacent node of the node;
第二生成模块603,根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。The second generating module 603 generates a random sequence according to the two-dimensional array, where the random sequence reflects the random walk in the graph data.
可选地,所述集群包括服务器集群和工作机集群;Optionally, the cluster includes a server cluster and a worker cluster;
所述获取模块601获取图数据包含的各节点的信息,具体包括:The acquisition module 601 acquires information of each node included in the graph data, specifically including:
所述工作机集群从数据库读取图数据包含的各节点的相邻节点的标识,其中,每个工作机读取一部分节点的相邻节点的标识。The worker machine cluster reads the identifiers of the adjacent nodes of each node contained in the graph data from the database, wherein each worker machine reads the identifiers of the adjacent nodes of a portion of the nodes.
可选地,所述第一生成模块602根据所述各节点的信息,生成二维数组,具体包括:Optionally, the first generating module 602 generates a two-dimensional array according to the information of each node, specifically including:
各所述工作机分别根据自己读取标识的相邻节点及其对应节点的标识,生成非全量的二维数组;Each of the working machines generates a partial two-dimensional array according to the identification of the adjacent node and its corresponding node read by itself;
所述工作机集群将各所述非全量的二维数组向所述服务器集群同步;The worker cluster synchronizes each of the partial two-dimensional arrays to the server cluster;
所述服务器集群根据各所述非全量的二维数组,得到全量的二维数组。The server cluster obtains a full two-dimensional array based on each of the incomplete two-dimensional arrays.
可选地,所述第二生成模块603根据所述二维数组,生成随机序列前,所述服务器集群将所述全量的二维数组向各所述工作机同步,以便各所述工作机根据所述全量的二维数组,生成随机序列。Optionally, before the second generation module 603 generates a random sequence based on the two-dimensional array, the server cluster synchronizes the full two-dimensional array to each of the working machines so that each of the working machines generates a random sequence based on the full two-dimensional array.
可选地,所述第二生成模块603根据所述二维数组,生成随机序列,具体包括:Optionally, the second generating module 603 generates a random sequence according to the two-dimensional array, specifically including:
所述工作机根据节点标识顺序,对所述全量的二维数组中的各行进行排序;The working machine sorts each row in the two-dimensional array of the full amount according to the order of node identification;
根据排序后的二维数组,生成随机序列。Generate a random sequence based on a sorted two-dimensional array.
可选地,所述第二生成模块603根据所述二维数组,生成随机序列,具体包括:Optionally, the second generating module 603 generates a random sequence according to the two-dimensional array, specifically including:
所述工作机在所述各节点的标识中,随机确定一个标识,作为目标节点的标识;The working machine randomly determines an identifier from the identifiers of the nodes as the identifier of the target node;
根据所述目标节点的标识,在所述二维数组中索引得到对应的行,所述对应的行包括所述目标节点的标识,以及所述目标节点的相邻节点的标识;According to the identifier of the target node, indexing in the two-dimensional array obtains a corresponding row, wherein the corresponding row includes the identifier of the target node and identifiers of adjacent nodes of the target node;
确定所述对应的行包括的相邻节点的标识的数量;Determine the number of identifiers of adjacent nodes included in the corresponding row;
随机确定一个小于所述数量的非负整数,并获取所述对应的行包括的第所述非负整数个相邻节点的标识;Randomly determine a non-negative integer smaller than the number, and obtain the identifiers of the non-negative integer-th adjacent nodes included in the corresponding row;
通过将该第所述非负整数个相邻节点重新作为目标节点进行迭代计算,生成由依次得到的各目标节点的标识构成的随机序列。By re-using the non-negative integer number of adjacent nodes as target nodes for iterative calculation, a random sequence consisting of identifiers of the target nodes obtained in sequence is generated.
可选地,所述节点总数量为N,第m个所述节点的标识为m,0≤m≤N-1,所述目标节点为第i个节点,所述对应的行为所述二维数组的第i行。Optionally, the total number of nodes is N, the identifier of the mth node is m, 0≤m≤N-1, the target node is the ith node, and the corresponding row is the ith row of the two-dimensional array.
可选地,所述对应的行为一维数组,所述目标节点的第n个相邻节点的标识为该一维数组的第n个元素,n从0开始计数;Optionally, the corresponding row is a one-dimensional array, the identifier of the n-th adjacent node of the target node is the n-th element of the one-dimensional array, and n is counted starting from 0;
所述非负整数记作j,所述工作机获取所述对应的行包括的第所述非负整数个相邻节点的标识,具体包括:The non-negative integer is denoted as j, and the working machine obtains the identifier of the non-negative integer-th adjacent node included in the corresponding row, specifically including:
所述工作机通过读取该一维数组的第j个元素,得到所述目标节点的第j个相邻节点的标识。The working machine obtains the identifier of the jth adjacent node of the target node by reading the jth element of the one-dimensional array.
可选地,所述一维数组的元素总数量等于所述各节点中邻居节点最多的节点的邻居节点数量。Optionally, the total number of elements in the one-dimensional array is equal to the number of neighbor nodes of the node with the most neighbor nodes among the nodes.
可选地,所述工作机生成由依次得到的各目标节点的标识构成的随机序列,具体包括:Optionally, the working machine generates a random sequence consisting of identifiers of target nodes obtained in sequence, specifically including:
所述工作机当依次得到的各目标节点总数量达到预设的随机游走步数时,生成由所述依次得到的各目标节点的标识构成的随机序列。When the total number of target nodes obtained in sequence reaches a preset number of random walk steps, the working machine generates a random sequence consisting of identifiers of the target nodes obtained in sequence.
可选地,所述第二生成模块603生成随机序列,具体包括:Optionally, the second generating module 603 generates a random sequence, specifically including:
各所述工作机分别生成随机序列,直至生成的随机序列总数量达到设定阈值。Each of the working machines generates a random sequence respectively until the total number of generated random sequences reaches a set threshold.
可选地,所述工作机若本地已有的所述二维数组丢失,则重新从所述服务器集群获取。Optionally, if the two-dimensional array locally on the working machine is lost, it is retrieved from the server cluster again.
图7为本说明书实施例提供的对应于图5的一种随机游走装置的结构示意图,该装置包括:FIG7 is a schematic diagram of the structure of a random walk device corresponding to FIG5 provided in an embodiment of this specification, wherein the device includes:
获取模块701,获取根据图数据包含的各节点的信息生成的二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;An acquisition module 701 acquires a two-dimensional array generated based on information of each node included in the graph data, wherein each row of the two-dimensional array includes an identifier of an adjacent node of the node;
生成模块702,根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。The generating module 702 generates a random sequence according to the two-dimensional array, where the random sequence reflects a random walk in the graph data.
基于同样的思路,本说明书实施例还提供了对应于图2的一种基于集群的随机游走设备,该设备属于所述集群,包括:Based on the same idea, the embodiment of this specification also provides a cluster-based random walk device corresponding to FIG2 , which belongs to the cluster and includes:
至少一个处理器;以及,at least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
获取图数据包含的各节点的信息;Get the information of each node contained in the graph data;
根据所述各节点的信息,生成二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;Generate a two-dimensional array based on the information of each node, where each row of the two-dimensional array includes an identifier of an adjacent node of the node;
根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A random sequence is generated based on the two-dimensional array, where the random sequence reflects a random walk in the graph data.
基于同样的思路,本说明书实施例还提供了对应于图5的一种随机游走设备,包括:Based on the same idea, the embodiment of this specification also provides a random walk device corresponding to FIG5 , including:
至少一个处理器;以及,at least one processor; and,
与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein,
所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够:The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
获取根据图数据包含的各节点的信息生成的二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;Obtain a two-dimensional array generated according to information of each node included in the graph data, wherein each row of the two-dimensional array includes an identifier of an adjacent node of the node;
根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A random sequence is generated based on the two-dimensional array, where the random sequence reflects a random walk in the graph data.
基于同样的思路,本说明书实施例还提供了对应于图2的一种非易失性计算机存储介质,存储有计算机可执行指令,所述计算机可执行指令设置为:Based on the same idea, an embodiment of this specification further provides a non-volatile computer storage medium corresponding to FIG2 , storing computer-executable instructions, wherein the computer-executable instructions are configured as follows:
获取图数据包含的各节点的信息;Get the information of each node contained in the graph data;
根据所述各节点的信息,生成二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;Generate a two-dimensional array based on the information of each node, where each row of the two-dimensional array includes an identifier of an adjacent node of the node;
根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A random sequence is generated based on the two-dimensional array, where the random sequence reflects a random walk in the graph data.
基于同样的思路,本说明书实施例还提供了对应于图5的一种非易失性计算机存储介质,存储有计算机可执行指令,所述计算机可执行指令设置为:Based on the same idea, an embodiment of this specification also provides a non-volatile computer storage medium corresponding to FIG5 , storing computer-executable instructions, wherein the computer-executable instructions are configured as follows:
获取根据图数据包含的各节点的信息生成的二维数组,所述二维数组的每行分别包括一个所述节点的相邻节点的标识;Obtain a two-dimensional array generated according to information of each node included in the graph data, wherein each row of the two-dimensional array includes an identifier of an adjacent node of the node;
根据所述二维数组,生成随机序列,所述随机序列反映在所述图数据中的随机游走。A random sequence is generated based on the two-dimensional array, where the random sequence reflects a random walk in the graph data.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置、设备、非易失性计算机存储介质实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The various embodiments in this specification are described in a progressive manner. Similar portions between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the device, apparatus, and non-volatile computer storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simplified. For relevant details, refer to the descriptions of the method embodiments.
本说明书实施例提供的装置、设备、非易失性计算机存储介质与方法是对应的,因此,装置、设备、非易失性计算机存储介质也具有与对应方法类似的有益技术效果,由于上面已经对方法的有益技术效果进行了详细说明,因此,这里不再赘述对应装置、设备、非易失性计算机存储介质的有益技术效果。The apparatus, device, non-volatile computer storage medium and method provided in the embodiments of this specification correspond to each other. Therefore, the apparatus, device and non-volatile computer storage medium also have similar beneficial technical effects as the corresponding method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the corresponding apparatus, device and non-volatile computer storage medium will not be repeated here.
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如,对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable GateArray,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware DescriptionLanguage)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(RubyHardware Description Language)等,目前最普遍使用的是VHDL(Very-High-SpeedIntegrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。In the 1990s, technological improvements could be clearly distinguished as either hardware improvements (for example, improvements to circuit structures like diodes, transistors, and switches) or software improvements (improvements to process flows). However, with the advancement of technology, many process flow improvements today can now be considered direct improvements to hardware circuit structures. Designers almost always create the corresponding hardware circuit structure by programming the improved process flow into the hardware circuit. Therefore, it cannot be said that a process flow improvement cannot be implemented using hardware modules. For example, a programmable logic device (PLD), such as a field programmable gate array (FPGA), is an integrated circuit whose logical function is determined by user programming. Designers can "integrate" a digital system on a PLD through their own programming, without having to hire a chip manufacturer to design and manufacture a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly done using "logic compiler" software. This is similar to the software compiler used when developing programs. Before compilation, the original code must also be written in a specific programming language, called a hardware description language (HDL). There is not just one HDL, but many, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art will also understand that by simply programming the method flow in one of these hardware description languages and then programming it into an integrated circuit, a hardware circuit that implements the logic method flow can be easily obtained.
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。The controller can be implemented in any suitable manner. For example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that in addition to implementing the controller in a purely computer-readable program code format, the controller can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules that implement the method and structures within the hardware component.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本说明书时可以把各单元的功能在同一个或多个软件和/或硬件中实现。For the convenience of description, the above devices are described as being divided into various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and/or hardware.
本领域内的技术人员应明白,本说明书实施例可提供为方法、系统、或计算机程序产品。因此,本说明书实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本说明书实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, the embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
本说明书是参照根据本说明书实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。This specification is described with reference to the flowcharts and/or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and/or box in the flowchart and/or block diagram, as well as the combination of the processes and/or boxes in the flowchart and/or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
本说明书可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本说明书,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
以上所述仅为本说明书实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The foregoing is merely an embodiment of the present invention and is not intended to limit the present application. For those skilled in the art, various modifications and variations may be made to the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included within the scope of the claims of the present application.
Claims (15)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| HK18112979.0A HK1254034B (en) | 2018-10-11 | Cluster-based random walk method, device and equipment for random walk |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| HK18112979.0A HK1254034B (en) | 2018-10-11 | Cluster-based random walk method, device and equipment for random walk |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| HK1254034A1 HK1254034A1 (en) | 2019-07-12 |
| HK1254034B true HK1254034B (en) | 2021-03-05 |
Family
ID=
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP6804668B2 (en) | Block data validation method and equipment | |
| US11074246B2 (en) | Cluster-based random walk processing | |
| CN107957989B9 (en) | Cluster-based word vector processing method, device and equipment | |
| EP3547168A1 (en) | Block chain based data processing method and device | |
| TWI688903B (en) | Social content risk identification method, device and equipment | |
| WO2019020094A1 (en) | Method, device, and electronic apparatus for detecting indicator abnormality | |
| US10776334B2 (en) | Random walking and cluster-based random walking method, apparatus and device | |
| TW201918916A (en) | Random walking, and random walking method, apparatus and device based on distributed system | |
| Jiang et al. | Parallel K-Medoids clustering algorithm based on Hadoop | |
| US20200167527A1 (en) | Method, device, and apparatus for word vector processing based on clusters | |
| CN107451204B (en) | Data query method, device and equipment | |
| US10901971B2 (en) | Random walking and cluster-based random walking method, apparatus and device | |
| CN109446271B (en) | Data synchronization method, device, equipment and medium | |
| HK1254034B (en) | Cluster-based random walk method, device and equipment for random walk | |
| HK1254034A1 (en) | Cluster-based random walk method, device and equipment for random walk | |
| CN110851416B (en) | Data storage performance analysis method and device, host machine determination method and device | |
| HK1253990B (en) | Word vector processing method, device and equipment based on cluster | |
| CN118131159A (en) | A method, device and system for asynchronous track association based on pseudo nearest neighbor distance | |
| HK1253990A1 (en) | Word vector processing method, device and equipment based on cluster | |
| HK1255563A1 (en) | Cluster-based word vector processing method, apparatus and device |