How to check graph connectivity between two vertices

I'm trying to implement a genetic algorithm to find a set of edges whose removal will disconnect the graph. To be more specific I'm using a directed acyclic graph consisted of vertices and edges. Each edge has a cost or weight. The genetic algorithm generates lots of sets C (ie selects some edges in between two vertices). Now my problem is check whether this set of edges represents a

如何检查两个顶点之间的图形连通性

我试图实现一个遗传算法来找到一组边,这些边的移除将会断开图形。 更具体地说,我使用由顶点和边组成的有向无环图。 每条边都有成本或重量。 遗传算法生成大量集合C(即选择两个顶点之间的某些边)。 现在我的问题是检查这组边是否表示剪切集或断开图。 然后,遗传算法正在寻找包含在切割集合中的可能的最小边缘成本总和。 所以,我使用了从图书的算法和优化的Java库中提取的连接图测试这种方法来测试连通性。 这对我不

What causes a Java library to behave differently when called by JRuby?

I am new to the Java world, but am familiar with Ruby. I am trying to write a program that interacts with some third-party jar files. While the libraries seem to behave fine if called from Java, they behave incorrectly when I call them in JRuby. This is a problem because I would really like to use JRuby. For example, the two programs below try to do exactly the same thing but they produce di

什么原因导致Java库在被JRuby调用时行为有所不同?

我对Java世界很陌生,但熟悉Ruby。 我正在尝试编写一些与第三方jar文件交互的程序。 虽然图书馆似乎从Java调用时表现良好,但当我在JRuby中调用它们时,它们的行为不正确。 这是一个问题,因为我真的很想使用JRuby。 例如,下面的两个程序试图做同样的事情,但它们产生不同的输出: 这个Java程序的行为是正确的。 我在Netbeans下面开发了Java程序,并通过按F6(运行主项目)运行它。 项目的Libraries文件夹设置为“C:

NoClassDefFoundError in web application running on Tomcat 7

I have web application written in Java using gucie-servlet framework being built by Maven 3. When I deploy it on Tomcat 7 container and try to access it using browser, Tomcat replies with 404 status code. This is log from Tomcat: Apr 4, 2013 11:39:50 AM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextDestroyed() Apr 4, 2013 11:39:50 AM org.apache.catalina.core.Appl

Tomcat 7上运行的Web应用程序中的NoClassDefFoundError

我有使用由Maven 3构建的gucie-servlet框架以Java编写的Web应用程序。当我将它部署在Tomcat 7容器上并尝试使用浏览器访问它时,Tomcat使用404状态代码进行回复。 这是来自Tomcat的日志: Apr 4, 2013 11:39:50 AM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextDestroyed() Apr 4, 2013 11:39:50 AM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextDestroy

Unable to receive proper UDP packets using SSDP

I'm trying to implement a very simple SSDP functionality into my android app taken from here. My application sends some UDP packets containing a relevant M-SEARCH message to the broadcasting address without any issue. The problem is, I should be getting a proper response back from other devices that's running a UPNP server. For some reason, I'm only receiving the exact same packet

无法使用SSDP接收正确的UDP数据包

我试图在我的Android应用程序中实现一个非常简单的SSDP功能。 我的应用程序发送一些包含相关M-SEARCH消息的UDP数据包给广播地址,没有任何问题。 问题是,我应该从运行UPNP服务器的其他设备获得正确的响应。 出于某种原因,我只收到从我的Android设备发回的完全相同的数据包。 MainActivity.java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

URI vs URL vs URN

Well there are lot of discussion, post, comments and questions over internet to differentiate URI, URL and URN. One answer on SO explain about it, but i am confused in implementation result in my code. Q : If URI is super set of URL then how come it got this following output: URI : /XXX/abc.do URL : http://examplehost:8080/XXX/abc.do When i write the below code: System.out.println(“URI :

URI与URL与URN

那么在互联网上有很多讨论,发布,评论和问题来区分URI,URL和URN。 一个关于它的答案解释了这一点,但我对我的代码中的实现结果感到困惑。 问:如果URI是URL的超级集合,那么它如何得到以下输出: URI : /XXX/abc.do URL : http://examplehost:8080/XXX/abc.do 当我写下面的代码: System.out.println(“URI : “+ httpRequestObj.getRequestURI()); System.out.println(“URL : “+ httpRequestObj.getRequestURL()); 编

Reverse a string in Java

I have "Hello World" kept in a String variable named hi . I need to print it, but reversed. How can I do this? I understand there is some kind of a function already built-in into Java that does that. Related: Reverse each individual word of “Hello World” string with Java You can use this: new StringBuilder(hi).reverse().toString() Or, for versions earlier than JDK 1.5, use ja

在Java中反转字符串

我将"Hello World"保存在一个名为hi的String变量中。 我需要打印它,但相反。 我怎样才能做到这一点? 我知道Java中已经内置了某种功能,可以实现这一点。 相关:用Java反转“Hello World”字符串中的每个单词 你可以使用这个: new StringBuilder(hi).reverse().toString() 或者,对于早于JDK 1.5的版本,请使用java.util.StringBuffer而不是StringBuilder - 它们具有相同的API。 感谢评论员指出,现在Stri

Access Google Talk chat history

I'm looking for a method to access Google Talk chat history. Method to be used for an android device but does not have to be specific to it. I am looking for preferably an official method, but this is not required. AFAIK there is no official method. The method must pecifically not, Through IMAP (requires chat and label to be enabled) Through Talk.apk's ContentResolver (requires th

访问Google Talk聊天记录

我正在寻找访问Google Talk聊天记录的方法。 要用于Android设备的方法,但不一定要特定于它。 我正在寻找最好的官方方法,但这不是必需的。 AFAIK没有官方的方法。 该方法必须pecifically不, 通过IMAP(需要启用聊天和标签) 通过Talk.apk的ContentResolver(需要安装talk.apk) 除非它以某种方式绕过上述方法之后列出的问题。 谷歌不同的Google Talk应用程序可以做聊天记录,但没有任何文件知道它如何工作。 Goo

Brackets in a Request URL are legal but not in a URI (Java)?

Apparently brackets are not allowed in URI paths. I'm not sure if this is a Tomcat problem but I'm getting request with paths that contains ] . In otherwords request.getRequestURL() == "http://localhost:8080/a]b" request.getRequestURI() == "/a]b" BTW getRequestURL() and URI are generally escaped ie for http://localhost:8080/ab request.getRequestURL() == "http://localhost:8080/a%20b

请求URL中的括号是合法的,但不在URI(Java)中?

显然,在URI路径中不允许使用括号。 我不确定这是否是一个Tomcat问题,但我得到的请求包含路径] 。 换一种说法 request.getRequestURL() == "http://localhost:8080/a]b" request.getRequestURI() == "/a]b" BTW getRequestURL()和URI通常会被转义,例如http://localhost:8080/ab request.getRequestURL() == "http://localhost:8080/a%20b" 所以如果你尝试做: new URI("http://localhost:8080/a]b") new URI(request

java.net.URISyntaxException: Illegal character in path at index 75

I'm trying to send GET request from java through Apache REST client and encountered this issue. java.net.URISyntaxException: Illegal character in path at index 75: http://torrento.sharepoint.com/_api/web/getfolderbyserverrelativeurl('/Shared Documents/test')/files at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.checkChars(URI.java:3021) at java.net.URI$Parser.parse

java.net.URISyntaxException:索引为75的路径中的非法字符

我试图通过Apache REST客户端从Java发送GET请求,并遇到此问题。 java.net.URISyntaxException:位于索引75处的路径中的非法字符:http://resolver.sharepoint.com/_api/web/getfolderbyserverrelativeurl('/Shared Documents / test')/ files at java.net.URI $ Parser.fail (URI.java:2848)at java.net.URI $ Parser.checkChars(URI.java:3021)位于java.net.URI $ Parser.parseHierarchical(URI.java:3105)位

How to add zip entry with utf

I have a method which adds inputStream to zip as an entry: private void addToZip(InputStream is, String filename) throws Exception { try { ZipEntry zipEntry = new ZipEntry(filename); zos.putNextEntry(zipEntry); byte[] bytes = new byte[1024]; int length; while ((length = is.read(bytes)) >= 0) { zos.write(bytes, 0, length); }

如何使用utf添加zip条目

我有一个方法将inputStream添加为zip作为条目: private void addToZip(InputStream is, String filename) throws Exception { try { ZipEntry zipEntry = new ZipEntry(filename); zos.putNextEntry(zipEntry); byte[] bytes = new byte[1024]; int length; while ((length = is.read(bytes)) >= 0) { zos.write(bytes, 0, length); } zos.closeEn